@classic-homes/auth 1.42.0 → 1.42.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/{auth.svelte-XY4FQFZQ.js → auth.svelte-FUCU4DYP.js} +2 -2
- package/dist/{chunk-LPQKZRPC.js → chunk-A6JJQCBU.js} +2 -2
- package/dist/{chunk-7JLCFRUU.js → chunk-G6UH4HBI.js} +2 -2
- package/dist/{chunk-MBVOLE5U.js → chunk-IR6DVUUF.js} +1 -1
- package/dist/{chunk-7AQYLLTA.js → chunk-QV3DUSP5.js} +55 -36
- 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-IR6DVUUF.js';
|
|
2
|
+
import './chunk-QV3DUSP5.js';
|
|
3
3
|
import './chunk-K6TV3ZVS.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { authApi, InvalidAuthResponseError, RoleDeniedError } from './chunk-
|
|
1
|
+
import { authApi, InvalidAuthResponseError, RoleDeniedError } from './chunk-QV3DUSP5.js';
|
|
2
2
|
import { hasAnyRole, getUserRoles } from './chunk-K6TV3ZVS.js';
|
|
3
3
|
|
|
4
4
|
// src/core/guards.ts
|
|
@@ -19,7 +19,7 @@ function getAvailableMethods(response) {
|
|
|
19
19
|
async function setStoreAuth(response) {
|
|
20
20
|
let store;
|
|
21
21
|
try {
|
|
22
|
-
store = (await import('./auth.svelte-
|
|
22
|
+
store = (await import('./auth.svelte-FUCU4DYP.js')).authStore;
|
|
23
23
|
} catch {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { authService } from './chunk-
|
|
2
|
-
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-
|
|
1
|
+
import { authService } from './chunk-A6JJQCBU.js';
|
|
2
|
+
import { authStore, currentUser, isAuthenticated, authActions } from './chunk-IR6DVUUF.js';
|
|
3
3
|
import { isInitialized, initAuth, getUserRoles } from './chunk-K6TV3ZVS.js';
|
|
4
4
|
|
|
5
5
|
// src/svelte/guards/auth-guard.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidAuthResponseError, bumpSessionGeneration, authApi } from './chunk-
|
|
1
|
+
import { InvalidAuthResponseError, bumpSessionGeneration, authApi } from './chunk-QV3DUSP5.js';
|
|
2
2
|
import { isInitialized, getConfig, isValidSSOLogoutUrl, hasRole, hasAnyRole, hasAllRoles, decodeJWT, getStorage, getDefaultStorage } from './chunk-K6TV3ZVS.js';
|
|
3
3
|
|
|
4
4
|
// src/svelte/stores/auth.svelte.ts
|
|
@@ -218,7 +218,7 @@ function writeStoredTokens(accessToken, refreshToken) {
|
|
|
218
218
|
}
|
|
219
219
|
async function syncSvelteStore(apply) {
|
|
220
220
|
try {
|
|
221
|
-
const { authStore } = await import('./auth.svelte-
|
|
221
|
+
const { authStore } = await import('./auth.svelte-FUCU4DYP.js');
|
|
222
222
|
apply(authStore);
|
|
223
223
|
} catch {
|
|
224
224
|
}
|
|
@@ -439,7 +439,6 @@ async function apiRequestInternal(endpoint, options, isRetry, startedIn) {
|
|
|
439
439
|
body: body ? JSON.stringify(body) : void 0,
|
|
440
440
|
signal: controller.signal
|
|
441
441
|
});
|
|
442
|
-
clearTimeout(timeoutId);
|
|
443
442
|
if (response.status === 401 && authenticated && !noAuthRetry && typeof window !== "undefined") {
|
|
444
443
|
await assertSameSession();
|
|
445
444
|
if (isRetry) {
|
|
@@ -462,13 +461,17 @@ async function apiRequestInternal(endpoint, options, isRetry, startedIn) {
|
|
|
462
461
|
try {
|
|
463
462
|
data = await response.json();
|
|
464
463
|
} catch (parseError) {
|
|
464
|
+
if (controller.signal.aborted) throw parseError;
|
|
465
465
|
if (!response.ok) {
|
|
466
466
|
throw new Error(`Server error (${response.status}): Invalid JSON response`);
|
|
467
467
|
}
|
|
468
468
|
throw parseError;
|
|
469
469
|
}
|
|
470
470
|
} else {
|
|
471
|
-
const responseText = await response.text().catch(() =>
|
|
471
|
+
const responseText = await response.text().catch((readError) => {
|
|
472
|
+
if (controller.signal.aborted) throw readError;
|
|
473
|
+
return "";
|
|
474
|
+
});
|
|
472
475
|
if (responseText) {
|
|
473
476
|
try {
|
|
474
477
|
data = JSON.parse(responseText);
|
|
@@ -499,7 +502,6 @@ async function apiRequestInternal(endpoint, options, isRetry, startedIn) {
|
|
|
499
502
|
}
|
|
500
503
|
return data;
|
|
501
504
|
} catch (error) {
|
|
502
|
-
clearTimeout(timeoutId);
|
|
503
505
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
504
506
|
if (signal?.aborted) throw error;
|
|
505
507
|
throw new Error(`Request timed out after ${timeoutMs}ms`);
|
|
@@ -509,6 +511,7 @@ async function apiRequestInternal(endpoint, options, isRetry, startedIn) {
|
|
|
509
511
|
}
|
|
510
512
|
throw new Error("API request failed");
|
|
511
513
|
} finally {
|
|
514
|
+
clearTimeout(timeoutId);
|
|
512
515
|
signal?.removeEventListener("abort", onCallerAbort);
|
|
513
516
|
}
|
|
514
517
|
}
|
|
@@ -553,16 +556,19 @@ var api = {
|
|
|
553
556
|
};
|
|
554
557
|
|
|
555
558
|
// src/core/api.ts
|
|
556
|
-
async function fetchWithTimeout(url, init) {
|
|
559
|
+
async function fetchWithTimeout(url, init, read) {
|
|
557
560
|
const config = getConfig();
|
|
558
561
|
const fetchFn = config.fetch ?? fetch;
|
|
559
562
|
const timeoutMs = config.requestTimeout ?? 3e4;
|
|
560
563
|
const controller = new AbortController();
|
|
561
564
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
562
565
|
try {
|
|
563
|
-
|
|
566
|
+
const response = await fetchFn(url, { ...init, signal: controller.signal });
|
|
567
|
+
const result = await read(response);
|
|
568
|
+
if (controller.signal.aborted) throw new Error("aborted");
|
|
569
|
+
return result;
|
|
564
570
|
} catch (error) {
|
|
565
|
-
if (
|
|
571
|
+
if (controller.signal.aborted) {
|
|
566
572
|
throw new Error(`Request timed out after ${timeoutMs}ms`);
|
|
567
573
|
}
|
|
568
574
|
throw error;
|
|
@@ -814,19 +820,24 @@ var authApi = {
|
|
|
814
820
|
type: data.method === "backup" || data.method === "email" ? data.method : "totp",
|
|
815
821
|
trustDevice: data.trustDevice
|
|
816
822
|
};
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
823
|
+
const result = await fetchWithTimeout(
|
|
824
|
+
`${config.baseUrl}/auth/mfa/challenge`,
|
|
825
|
+
{
|
|
826
|
+
method: "POST",
|
|
827
|
+
headers: {
|
|
828
|
+
"Content-Type": "application/json",
|
|
829
|
+
Authorization: `Bearer ${data.mfaToken}`
|
|
830
|
+
},
|
|
831
|
+
body: JSON.stringify(requestBody)
|
|
822
832
|
},
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
833
|
+
async (response) => {
|
|
834
|
+
if (!response.ok) {
|
|
835
|
+
const error = await response.json().catch(() => ({ message: "Verification failed" }));
|
|
836
|
+
throw new Error(error.error?.message || error.message || "Invalid verification code");
|
|
837
|
+
}
|
|
838
|
+
return response.json();
|
|
839
|
+
}
|
|
840
|
+
);
|
|
830
841
|
return extractData(result);
|
|
831
842
|
},
|
|
832
843
|
/**
|
|
@@ -837,11 +848,14 @@ var authApi = {
|
|
|
837
848
|
*/
|
|
838
849
|
async sendMFAChallengeEmail(mfaToken) {
|
|
839
850
|
const config = getConfig();
|
|
840
|
-
const response = await fetchWithTimeout(
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
851
|
+
const { response, body } = await fetchWithTimeout(
|
|
852
|
+
`${config.baseUrl}/auth/mfa/challenge/email/send`,
|
|
853
|
+
{
|
|
854
|
+
method: "POST",
|
|
855
|
+
headers: { Authorization: `Bearer ${mfaToken}` }
|
|
856
|
+
},
|
|
857
|
+
async (response2) => ({ response: response2, body: await response2.json().catch(() => ({})) })
|
|
858
|
+
);
|
|
845
859
|
if (!response.ok) {
|
|
846
860
|
const details = body?.error?.details;
|
|
847
861
|
const retryAfter = typeof details?.retryAfterSeconds === "number" ? details.retryAfterSeconds : typeof body?.retryAfterSeconds === "number" ? body.retryAfterSeconds : void 0;
|
|
@@ -969,19 +983,24 @@ var authApi = {
|
|
|
969
983
|
throw new Error("Not authenticated");
|
|
970
984
|
}
|
|
971
985
|
const config = getConfig();
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
986
|
+
const result = await fetchWithTimeout(
|
|
987
|
+
`${config.baseUrl}/auth/sso/link`,
|
|
988
|
+
{
|
|
989
|
+
method: "POST",
|
|
990
|
+
headers: {
|
|
991
|
+
"Content-Type": "application/json",
|
|
992
|
+
Authorization: `Bearer ${accessToken}`
|
|
993
|
+
},
|
|
994
|
+
body: JSON.stringify({ provider })
|
|
977
995
|
},
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
996
|
+
async (response) => {
|
|
997
|
+
if (!response.ok) {
|
|
998
|
+
const error = await response.json().catch(() => ({ message: "Failed to link SSO account" }));
|
|
999
|
+
throw new Error(error.error?.message || error.message || "Failed to link SSO account");
|
|
1000
|
+
}
|
|
1001
|
+
return response.json();
|
|
1002
|
+
}
|
|
1003
|
+
);
|
|
985
1004
|
const authorizationUrl = extractData(result).authorizationUrl;
|
|
986
1005
|
if (authorizationUrl) {
|
|
987
1006
|
if (!isValidRedirectUrl(authorizationUrl)) {
|
package/dist/core/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from '../chunk-
|
|
2
|
-
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from '../chunk-
|
|
1
|
+
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from '../chunk-A6JJQCBU.js';
|
|
2
|
+
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from '../chunk-QV3DUSP5.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-K6TV3ZVS.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, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from './chunk-
|
|
3
|
-
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-
|
|
4
|
-
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from './chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from './chunk-G6UH4HBI.js';
|
|
2
|
+
export { AuthService, authService, formatUserRoles, getAvailableMethods, getAvatarFallback, getDisplayName, getGreeting, getMfaToken, getUserEmail, getUserInitials, isLoginSuccessResponse, isMfaChallengeResponse } from './chunk-A6JJQCBU.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from './chunk-IR6DVUUF.js';
|
|
4
|
+
export { InvalidAuthResponseError, MFAChallengeEmailError, RoleDeniedError, SSO_CLIENT_STATE_PARAM, SSO_CLIENT_STATE_TTL_MS, SessionChangedError, api, apiRequest, authApi, clearStoredAuth, consumeSsoClientState, createSsoClientState, extractData, getAccessToken, getRefreshToken, getSessionToken, initCrossTabSync, isRoleDeniedError, isSessionChangedError, refreshSession, updateStoredTokens, verifySsoClientState } from './chunk-QV3DUSP5.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-K6TV3ZVS.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 { formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials } from '../chunk-
|
|
3
|
-
export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-
|
|
4
|
-
export { InvalidAuthResponseError, RoleDeniedError, SessionChangedError, isRoleDeniedError, isSessionChangedError } from '../chunk-
|
|
1
|
+
export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-G6UH4HBI.js';
|
|
2
|
+
export { formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials } from '../chunk-A6JJQCBU.js';
|
|
3
|
+
export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-IR6DVUUF.js';
|
|
4
|
+
export { InvalidAuthResponseError, RoleDeniedError, SessionChangedError, isRoleDeniedError, isSessionChangedError } from '../chunk-QV3DUSP5.js';
|
|
5
5
|
export { initAuth, isInitialized } from '../chunk-K6TV3ZVS.js';
|