@shipfox/client-auth 6.0.1 → 6.0.3

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.
Files changed (42) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +20 -0
  3. package/dist/components/redirect-context.d.ts.map +1 -1
  4. package/dist/components/redirect-context.js +6 -9
  5. package/dist/components/redirect-context.js.map +1 -1
  6. package/dist/components/redirect-target.d.ts +7 -0
  7. package/dist/components/redirect-target.d.ts.map +1 -1
  8. package/dist/components/redirect-target.js +46 -12
  9. package/dist/components/redirect-target.js.map +1 -1
  10. package/dist/components/workspace-switcher.d.ts.map +1 -1
  11. package/dist/components/workspace-switcher.js +3 -2
  12. package/dist/components/workspace-switcher.js.map +1 -1
  13. package/dist/hooks/api/login-auth.js +1 -1
  14. package/dist/hooks/api/login-auth.js.map +1 -1
  15. package/dist/hooks/api/logout-auth.js +1 -1
  16. package/dist/hooks/api/logout-auth.js.map +1 -1
  17. package/dist/hooks/api/password-reset-auth.js +1 -1
  18. package/dist/hooks/api/password-reset-auth.js.map +1 -1
  19. package/dist/hooks/api/verify-email-auth.js +1 -1
  20. package/dist/hooks/api/verify-email-auth.js.map +1 -1
  21. package/dist/pages/workspace-onboarding-page.d.ts.map +1 -1
  22. package/dist/pages/workspace-onboarding-page.js +4 -1
  23. package/dist/pages/workspace-onboarding-page.js.map +1 -1
  24. package/dist/routes/index.d.ts.map +1 -1
  25. package/dist/routes/index.js +4 -3
  26. package/dist/routes/index.js.map +1 -1
  27. package/dist/tsconfig.test.tsbuildinfo +1 -1
  28. package/package.json +7 -7
  29. package/src/components/auth-provider.test.tsx +132 -19
  30. package/src/components/redirect-context.test.ts +13 -0
  31. package/src/components/redirect-context.ts +5 -8
  32. package/src/components/redirect-target.test.ts +47 -2
  33. package/src/components/redirect-target.ts +54 -12
  34. package/src/components/workspace-switcher.tsx +3 -2
  35. package/src/hooks/api/login-auth.ts +1 -1
  36. package/src/hooks/api/logout-auth.ts +1 -1
  37. package/src/hooks/api/password-reset-auth.ts +1 -1
  38. package/src/hooks/api/verify-email-auth.ts +1 -1
  39. package/src/pages/workspace-onboarding-page.tsx +4 -1
  40. package/src/routes/index.tsx +5 -3
  41. package/src/state/last-workspace.test.ts +21 -28
  42. package/tsconfig.build.tsbuildinfo +1 -1
@@ -5,7 +5,7 @@ import {
5
5
  rememberLastWorkspaceId,
6
6
  } from './last-workspace.js';
7
7
 
8
- describe('lastWorkspaceIdAtom', () => {
8
+ describe('last workspace state', () => {
9
9
  beforeEach(() => {
10
10
  window.localStorage.clear();
11
11
  });
@@ -14,21 +14,13 @@ describe('lastWorkspaceIdAtom', () => {
14
14
  window.localStorage.clear();
15
15
  });
16
16
 
17
- test('initial value is undefined when storage is empty', () => {
18
- const store = createStore();
19
-
20
- expect(store.get(lastWorkspaceIdAtom)).toBeUndefined();
21
- });
22
-
23
- test('write persists to localStorage and round-trips through the atom', () => {
17
+ test('atom stores current UI selection without unscoped persistence', () => {
24
18
  const store = createStore();
25
19
 
26
20
  store.set(lastWorkspaceIdAtom, 'workspace-1');
27
21
 
28
- expect(JSON.parse(window.localStorage.getItem('shipfox.lastWorkspaceId') ?? 'null')).toBe(
29
- 'workspace-1',
30
- );
31
22
  expect(store.get(lastWorkspaceIdAtom)).toBe('workspace-1');
23
+ expect(window.localStorage.getItem('shipfox.lastWorkspaceId')).toBeNull();
32
24
  });
33
25
 
34
26
  test('subscribers receive updates when the atom is set', () => {
@@ -45,34 +37,35 @@ describe('lastWorkspaceIdAtom', () => {
45
37
  unsubscribe();
46
38
  });
47
39
 
48
- test('syncs the atom when another tab updates last workspace storage', () => {
49
- const store = createStore();
50
- const unsubscribe = store.sub(lastWorkspaceIdAtom, () => undefined);
51
- window.localStorage.setItem('shipfox.lastWorkspaceId', JSON.stringify('workspace-2'));
52
-
53
- window.dispatchEvent(
54
- new StorageEvent('storage', {
55
- key: 'shipfox.lastWorkspaceId',
56
- storageArea: window.localStorage,
57
- }),
58
- );
40
+ test('write persists to localStorage and can be read for the same principal', () => {
41
+ rememberLastWorkspaceId('principal-1', 'workspace-1');
59
42
 
60
- expect(store.get(lastWorkspaceIdAtom)).toBe('workspace-2');
61
- unsubscribe();
43
+ expect(
44
+ JSON.parse(
45
+ window.localStorage.getItem('shipfox.lastWorkspaceId.principal.principal-1') ?? 'null',
46
+ ),
47
+ ).toBe('workspace-1');
48
+ expect(getLastWorkspaceId('principal-1')).toBe('workspace-1');
62
49
  });
63
50
 
64
51
  test('rememberLastWorkspaceId persists a root redirect target', () => {
65
- rememberLastWorkspaceId('workspace-1');
52
+ rememberLastWorkspaceId('principal-1', 'workspace-1');
66
53
 
67
- const result = getLastWorkspaceId();
54
+ const result = getLastWorkspaceId('principal-1');
68
55
 
69
56
  expect(result).toBe('workspace-1');
70
57
  });
71
58
 
59
+ test("does not reuse a different principal's root redirect target", () => {
60
+ rememberLastWorkspaceId('principal-a', 'workspace-a');
61
+
62
+ expect(getLastWorkspaceId('principal-b')).toBeUndefined();
63
+ });
64
+
72
65
  test('getLastWorkspaceId ignores malformed storage', () => {
73
- window.localStorage.setItem('shipfox.lastWorkspaceId', '{');
66
+ window.localStorage.setItem('shipfox.lastWorkspaceId.principal.principal-1', '{');
74
67
 
75
- const result = getLastWorkspaceId();
68
+ const result = getLastWorkspaceId('principal-1');
76
69
 
77
70
  expect(result).toBeUndefined();
78
71
  });