@classic-homes/auth 1.5.2 → 1.8.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/dist/{auth.svelte-YNXMXION.js → auth.svelte-FIHKI5BD.js} +2 -2
- package/dist/{chunk-ZJYMNGGH.js → chunk-EBTCVIUQ.js} +1 -1
- package/dist/{chunk-NCVJ2HGP.js → chunk-HVOZBQIF.js} +4 -4
- package/dist/{chunk-O6GYC4PA.js → chunk-QTX7L4QY.js} +3 -3
- package/dist/{chunk-GVNUEBEP.js → chunk-UGD4PNYI.js} +2 -2
- package/dist/core/index.d.ts +14 -6
- package/dist/core/index.js +2 -2
- package/dist/index.js +4 -4
- package/dist/svelte/index.js +4 -4
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-EBTCVIUQ.js';
|
|
2
|
+
import './chunk-HVOZBQIF.js';
|
|
3
3
|
import './chunk-X7KH4DDN.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { authApi } from './chunk-
|
|
1
|
+
import { authApi } from './chunk-HVOZBQIF.js';
|
|
2
2
|
import { isInitialized, getConfig, hasRole, hasAnyRole, hasAllRoles, decodeJWT, getStorage, getDefaultStorage } from './chunk-X7KH4DDN.js';
|
|
3
3
|
|
|
4
4
|
// src/svelte/stores/auth.svelte.ts
|
|
@@ -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-
|
|
80
|
+
import('./auth.svelte-FIHKI5BD.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-
|
|
95
|
+
const { authStore } = await import('./auth.svelte-FIHKI5BD.js');
|
|
96
96
|
authStore.handleSessionExpired();
|
|
97
97
|
} catch {
|
|
98
98
|
}
|
|
@@ -302,8 +302,8 @@ async function apiRequestInternal(endpoint, options, isRetry) {
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
if (!response.ok) {
|
|
305
|
-
const
|
|
306
|
-
const errorMessage =
|
|
305
|
+
const errorBody = data ?? {};
|
|
306
|
+
const errorMessage = errorBody.error?.message || (typeof errorBody.message === "string" ? errorBody.message : void 0) || errorBody.meta?.message || (typeof errorBody.detail === "string" ? errorBody.detail : void 0) || `Request failed (${response.status})`;
|
|
307
307
|
const error = new Error(errorMessage);
|
|
308
308
|
config.onAuthError?.(error);
|
|
309
309
|
throw error;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { authApi } from './chunk-
|
|
1
|
+
import { authApi } from './chunk-HVOZBQIF.js';
|
|
2
2
|
import { getUserRoles, hasAnyRole } from './chunk-X7KH4DDN.js';
|
|
3
3
|
|
|
4
4
|
// src/core/guards.ts
|
|
@@ -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-
|
|
62
|
+
const { authStore } = await import('./auth.svelte-FIHKI5BD.js');
|
|
63
63
|
authStore.setAuth(
|
|
64
64
|
response.accessToken,
|
|
65
65
|
response.refreshToken,
|
|
@@ -245,7 +245,7 @@ var AuthService = class {
|
|
|
245
245
|
}
|
|
246
246
|
if (options?.autoSetAuth !== false) {
|
|
247
247
|
try {
|
|
248
|
-
const { authStore } = await import('./auth.svelte-
|
|
248
|
+
const { authStore } = await import('./auth.svelte-FIHKI5BD.js');
|
|
249
249
|
authStore.setAuth(
|
|
250
250
|
response.accessToken,
|
|
251
251
|
response.refreshToken,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { authService } from './chunk-
|
|
2
|
-
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-
|
|
1
|
+
import { authService } from './chunk-QTX7L4QY.js';
|
|
2
|
+
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-EBTCVIUQ.js';
|
|
3
3
|
import { isInitialized, initAuth, getUserRoles } from './chunk-X7KH4DDN.js';
|
|
4
4
|
|
|
5
5
|
// src/svelte/guards/auth-guard.ts
|
package/dist/core/index.d.ts
CHANGED
|
@@ -20,6 +20,14 @@ interface ApiRequestOptions extends Omit<RequestInit, 'body' | 'signal'> {
|
|
|
20
20
|
/** AbortSignal for manual cancellation */
|
|
21
21
|
signal?: AbortSignal;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The CHAPI envelope shape, for endpoints that wrap their payload in `data`.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: this is NOT the return type of `apiRequest`/`api.*`. Those resolve to
|
|
27
|
+
* the parsed response body itself — pass the envelope as the type argument
|
|
28
|
+
* (`api.get<{ data: User }>(...)`) and unwrap with `extractData` when the
|
|
29
|
+
* endpoint actually wraps. Many CHAPI endpoints return their payload bare.
|
|
30
|
+
*/
|
|
23
31
|
interface ApiResponse<T = unknown> {
|
|
24
32
|
data?: T;
|
|
25
33
|
meta?: {
|
|
@@ -72,16 +80,16 @@ declare function extractData<T>(response: {
|
|
|
72
80
|
/**
|
|
73
81
|
* Make an API request.
|
|
74
82
|
*/
|
|
75
|
-
declare function apiRequest<T = unknown>(endpoint: string, options?: ApiRequestOptions): Promise<
|
|
83
|
+
declare function apiRequest<T = unknown>(endpoint: string, options?: ApiRequestOptions): Promise<T>;
|
|
76
84
|
/**
|
|
77
85
|
* Convenience methods for common HTTP methods.
|
|
78
86
|
*/
|
|
79
87
|
declare const api: {
|
|
80
|
-
get: <T = unknown>(endpoint: string, authenticated?: boolean, customFetch?: typeof fetch) => Promise<
|
|
81
|
-
post: <T = unknown>(endpoint: string, body: unknown, authenticated?: boolean, customFetch?: typeof fetch) => Promise<
|
|
82
|
-
put: <T = unknown>(endpoint: string, body: unknown, authenticated?: boolean, customFetch?: typeof fetch) => Promise<
|
|
83
|
-
patch: <T = unknown>(endpoint: string, body: unknown, authenticated?: boolean, customFetch?: typeof fetch) => Promise<
|
|
84
|
-
delete: <T = unknown>(endpoint: string, authenticated?: boolean, customFetch?: typeof fetch, body?: unknown) => Promise<
|
|
88
|
+
get: <T = unknown>(endpoint: string, authenticated?: boolean, customFetch?: typeof fetch) => Promise<T>;
|
|
89
|
+
post: <T = unknown>(endpoint: string, body: unknown, authenticated?: boolean, customFetch?: typeof fetch) => Promise<T>;
|
|
90
|
+
put: <T = unknown>(endpoint: string, body: unknown, authenticated?: boolean, customFetch?: typeof fetch) => Promise<T>;
|
|
91
|
+
patch: <T = unknown>(endpoint: string, body: unknown, authenticated?: boolean, customFetch?: typeof fetch) => Promise<T>;
|
|
92
|
+
delete: <T = unknown>(endpoint: string, authenticated?: boolean, customFetch?: typeof fetch, body?: unknown) => Promise<T>;
|
|
85
93
|
};
|
|
86
94
|
|
|
87
95
|
/**
|
package/dist/core/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from '../chunk-
|
|
2
|
-
export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from '../chunk-
|
|
1
|
+
export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from '../chunk-QTX7L4QY.js';
|
|
2
|
+
export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from '../chunk-HVOZBQIF.js';
|
|
3
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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-
|
|
2
|
-
export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from './chunk-
|
|
3
|
-
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-
|
|
4
|
-
export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from './chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-UGD4PNYI.js';
|
|
2
|
+
export { AuthService, RoleDeniedError, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse, isRoleDeniedError } from './chunk-QTX7L4QY.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-EBTCVIUQ.js';
|
|
4
|
+
export { api, apiRequest, authApi, clearStoredAuth, extractData, getAccessToken, getRefreshToken, getSessionToken, updateStoredTokens } from './chunk-HVOZBQIF.js';
|
|
5
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';
|
package/dist/svelte/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-
|
|
2
|
-
export { RoleDeniedError, formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials, isRoleDeniedError } from '../chunk-
|
|
3
|
-
export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-UGD4PNYI.js';
|
|
2
|
+
export { RoleDeniedError, formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials, isRoleDeniedError } from '../chunk-QTX7L4QY.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-EBTCVIUQ.js';
|
|
4
|
+
import '../chunk-HVOZBQIF.js';
|
|
5
5
|
export { initAuth, isInitialized } from '../chunk-X7KH4DDN.js';
|