@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.
@@ -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 config2 = {
1476
+ const config = {
1481
1477
  baseUrl,
1482
1478
  storageKey,
1483
1479
  storage: mockStorage,
1484
1480
  fetch: mockFetch.fetch
1485
1481
  };
1486
- initAuth(config2);
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/auth",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Authentication services and Svelte bindings for Classic Theme apps",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",