@classic-homes/auth 0.1.24 → 0.1.26
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-PKMR4LYT.js +3 -0
- package/dist/chunk-DCGC6CNV.js +98 -0
- package/dist/chunk-IO2LIH4I.js +66 -0
- package/dist/chunk-MI4B4ZRK.js +558 -0
- package/dist/chunk-MY664247.js +306 -0
- package/dist/chunk-U2YM3E3Q.js +269 -0
- package/dist/core/index.js +3 -1279
- package/dist/index.js +5 -1346
- package/dist/svelte/index.js +4 -988
- package/dist/testing/index.js +6 -30
- package/package.json +1 -1
package/dist/testing/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { initAuth, resetConfig, isTokenExpired, decodeJWT } from '../chunk-DCGC6CNV.js';
|
|
2
|
+
|
|
1
3
|
// src/testing/fixtures/users.ts
|
|
2
4
|
var mockUser = {
|
|
3
5
|
id: "user-123",
|
|
@@ -1456,12 +1458,6 @@ function createMockCurrentUser(store) {
|
|
|
1456
1458
|
}
|
|
1457
1459
|
};
|
|
1458
1460
|
}
|
|
1459
|
-
function initAuth(options) {
|
|
1460
|
-
({
|
|
1461
|
-
...options,
|
|
1462
|
-
storageKey: options.storageKey ?? "classic_auth"
|
|
1463
|
-
});
|
|
1464
|
-
}
|
|
1465
1461
|
|
|
1466
1462
|
// src/testing/helpers/setup.ts
|
|
1467
1463
|
function setupTestAuth(options = {}) {
|
|
@@ -1477,15 +1473,16 @@ function setupTestAuth(options = {}) {
|
|
|
1477
1473
|
const mockFetch = createMockFetch({ baseUrl, ...fetchOptions });
|
|
1478
1474
|
const mockStore = createMockAuthStore({ initialState: initialAuthState });
|
|
1479
1475
|
if (initConfig) {
|
|
1480
|
-
const
|
|
1476
|
+
const config = {
|
|
1481
1477
|
baseUrl,
|
|
1482
1478
|
storageKey,
|
|
1483
1479
|
storage: mockStorage,
|
|
1484
1480
|
fetch: mockFetch.fetch
|
|
1485
1481
|
};
|
|
1486
|
-
initAuth(
|
|
1482
|
+
initAuth(config);
|
|
1487
1483
|
}
|
|
1488
1484
|
const cleanup = () => {
|
|
1485
|
+
resetConfig();
|
|
1489
1486
|
mockStorage.reset();
|
|
1490
1487
|
mockFetch.reset();
|
|
1491
1488
|
mockStore.reset();
|
|
@@ -1545,6 +1542,7 @@ function initAuthWithMocks(mockFetch, mockStorage, options = {}) {
|
|
|
1545
1542
|
});
|
|
1546
1543
|
}
|
|
1547
1544
|
function resetTestAuth(mockFetch, mockStorage, mockStore) {
|
|
1545
|
+
resetConfig();
|
|
1548
1546
|
mockFetch?.reset();
|
|
1549
1547
|
mockStorage?.reset();
|
|
1550
1548
|
mockStore?.reset();
|
|
@@ -1791,28 +1789,6 @@ function configureSessionManagementFlow(mockFetch, sessionCount = 3) {
|
|
|
1791
1789
|
});
|
|
1792
1790
|
}
|
|
1793
1791
|
|
|
1794
|
-
// src/core/jwt.ts
|
|
1795
|
-
function decodeJWT(token) {
|
|
1796
|
-
try {
|
|
1797
|
-
const parts = token.split(".");
|
|
1798
|
-
if (parts.length !== 3) {
|
|
1799
|
-
return null;
|
|
1800
|
-
}
|
|
1801
|
-
const payload = parts[1];
|
|
1802
|
-
const decoded = atob(payload.replace(/-/g, "+").replace(/_/g, "/"));
|
|
1803
|
-
return JSON.parse(decoded);
|
|
1804
|
-
} catch {
|
|
1805
|
-
return null;
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
function isTokenExpired(token) {
|
|
1809
|
-
const payload = decodeJWT(token);
|
|
1810
|
-
if (!payload || !payload.exp) {
|
|
1811
|
-
return true;
|
|
1812
|
-
}
|
|
1813
|
-
return payload.exp * 1e3 < Date.now();
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
1792
|
// src/testing/helpers/assertions.ts
|
|
1817
1793
|
function assertAuthenticated(state, message = "Expected state to be authenticated") {
|
|
1818
1794
|
if (!state.isAuthenticated) {
|