@shipfox/client-auth 5.0.0 → 6.0.2

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 (120) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +57 -0
  3. package/dist/components/auth-guard.d.ts.map +1 -1
  4. package/dist/components/auth-guard.js +4 -4
  5. package/dist/components/auth-guard.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 +35 -4
  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/core/auth.d.ts +57 -0
  14. package/dist/core/auth.d.ts.map +1 -0
  15. package/dist/core/auth.js +3 -0
  16. package/dist/core/auth.js.map +1 -0
  17. package/dist/hooks/api/auth-mapper.d.ts +2 -17
  18. package/dist/hooks/api/auth-mapper.d.ts.map +1 -1
  19. package/dist/hooks/api/auth-mapper.js.map +1 -1
  20. package/dist/hooks/api/login-auth.d.ts +3 -6
  21. package/dist/hooks/api/login-auth.d.ts.map +1 -1
  22. package/dist/hooks/api/login-auth.js +3 -3
  23. package/dist/hooks/api/login-auth.js.map +1 -1
  24. package/dist/hooks/api/logout-auth.js +3 -3
  25. package/dist/hooks/api/logout-auth.js.map +1 -1
  26. package/dist/hooks/api/password-reset-auth.d.ts +5 -10
  27. package/dist/hooks/api/password-reset-auth.d.ts.map +1 -1
  28. package/dist/hooks/api/password-reset-auth.js +10 -7
  29. package/dist/hooks/api/password-reset-auth.js.map +1 -1
  30. package/dist/hooks/api/refresh-auth.d.ts +1 -1
  31. package/dist/hooks/api/refresh-auth.d.ts.map +1 -1
  32. package/dist/hooks/api/refresh-auth.js +1 -1
  33. package/dist/hooks/api/refresh-auth.js.map +1 -1
  34. package/dist/hooks/api/signup-auth.d.ts +2 -6
  35. package/dist/hooks/api/signup-auth.d.ts.map +1 -1
  36. package/dist/hooks/api/signup-auth.js +9 -2
  37. package/dist/hooks/api/signup-auth.js.map +1 -1
  38. package/dist/hooks/api/verify-email-auth.d.ts +4 -10
  39. package/dist/hooks/api/verify-email-auth.d.ts.map +1 -1
  40. package/dist/hooks/api/verify-email-auth.js +16 -6
  41. package/dist/hooks/api/verify-email-auth.js.map +1 -1
  42. package/dist/hooks/api/workspace-auth.d.ts +5 -7
  43. package/dist/hooks/api/workspace-auth.d.ts.map +1 -1
  44. package/dist/hooks/api/workspace-auth.js +6 -4
  45. package/dist/hooks/api/workspace-auth.js.map +1 -1
  46. package/dist/hooks/api/workspace-mapper.d.ts +1 -5
  47. package/dist/hooks/api/workspace-mapper.d.ts.map +1 -1
  48. package/dist/hooks/api/workspace-mapper.js.map +1 -1
  49. package/dist/pages/login-page.d.ts.map +1 -1
  50. package/dist/pages/login-page.js +4 -5
  51. package/dist/pages/login-page.js.map +1 -1
  52. package/dist/pages/logout-page.d.ts.map +1 -1
  53. package/dist/pages/logout-page.js +8 -18
  54. package/dist/pages/logout-page.js.map +1 -1
  55. package/dist/pages/password-reset-page.d.ts.map +1 -1
  56. package/dist/pages/password-reset-page.js +8 -7
  57. package/dist/pages/password-reset-page.js.map +1 -1
  58. package/dist/pages/signup-page.d.ts.map +1 -1
  59. package/dist/pages/signup-page.js +16 -10
  60. package/dist/pages/signup-page.js.map +1 -1
  61. package/dist/pages/workspace-onboarding-page.d.ts.map +1 -1
  62. package/dist/pages/workspace-onboarding-page.js +6 -3
  63. package/dist/pages/workspace-onboarding-page.js.map +1 -1
  64. package/dist/routes/index.d.ts.map +1 -1
  65. package/dist/routes/index.js +4 -3
  66. package/dist/routes/index.js.map +1 -1
  67. package/dist/routes/inputs.d.ts +9 -0
  68. package/dist/routes/inputs.d.ts.map +1 -0
  69. package/dist/routes/inputs.js +17 -0
  70. package/dist/routes/inputs.js.map +1 -0
  71. package/dist/routes/login.d.ts +2 -0
  72. package/dist/routes/login.d.ts.map +1 -1
  73. package/dist/routes/login.js +2 -0
  74. package/dist/routes/login.js.map +1 -1
  75. package/dist/routes/logout.d.ts +2 -0
  76. package/dist/routes/logout.d.ts.map +1 -1
  77. package/dist/routes/logout.js +2 -0
  78. package/dist/routes/logout.js.map +1 -1
  79. package/dist/routes/reset.d.ts +2 -0
  80. package/dist/routes/reset.d.ts.map +1 -1
  81. package/dist/routes/reset.js +2 -0
  82. package/dist/routes/reset.js.map +1 -1
  83. package/dist/routes/signup.d.ts +2 -0
  84. package/dist/routes/signup.d.ts.map +1 -1
  85. package/dist/routes/signup.js +2 -0
  86. package/dist/routes/signup.js.map +1 -1
  87. package/dist/tsconfig.test.tsbuildinfo +1 -1
  88. package/package.json +11 -12
  89. package/src/components/auth-guard.tsx +4 -2
  90. package/src/components/auth-provider.test.tsx +132 -19
  91. package/src/components/redirect-target.test.ts +32 -1
  92. package/src/components/redirect-target.ts +41 -4
  93. package/src/components/workspace-switcher.tsx +3 -2
  94. package/src/core/auth.ts +55 -0
  95. package/src/hooks/api/auth-mapper.ts +2 -12
  96. package/src/hooks/api/login-auth.ts +5 -4
  97. package/src/hooks/api/logout-auth.ts +3 -3
  98. package/src/hooks/api/password-reset-auth.test.ts +2 -2
  99. package/src/hooks/api/password-reset-auth.ts +11 -11
  100. package/src/hooks/api/refresh-auth.ts +1 -0
  101. package/src/hooks/api/signup-auth.ts +9 -3
  102. package/src/hooks/api/verify-email-auth.ts +20 -10
  103. package/src/hooks/api/workspace-auth.ts +10 -5
  104. package/src/hooks/api/workspace-mapper.ts +1 -6
  105. package/src/pages/login-page.tsx +4 -3
  106. package/src/pages/logout-page.test.tsx +75 -0
  107. package/src/pages/logout-page.tsx +9 -13
  108. package/src/pages/password-reset-page.tsx +5 -5
  109. package/src/pages/signup-page.tsx +14 -8
  110. package/src/pages/workspace-onboarding-page.tsx +6 -3
  111. package/src/routes/index.tsx +5 -3
  112. package/src/routes/inputs.test.ts +17 -0
  113. package/src/routes/inputs.ts +21 -0
  114. package/src/routes/login.tsx +2 -0
  115. package/src/routes/logout.tsx +2 -1
  116. package/src/routes/reset.tsx +2 -0
  117. package/src/routes/signup.tsx +2 -0
  118. package/src/state/last-workspace.test.ts +21 -28
  119. package/tsconfig.build.tsbuildinfo +1 -1
  120. package/vercel.json +5 -0
@@ -1,2 +1,2 @@
1
1
  $ shipfox-swc
2
- Successfully compiled: 39 files with swc (471.46ms)
2
+ Successfully compiled: 41 files with swc (106.33ms)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # @shipfox/client-auth
2
2
 
3
+ ## 6.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 102c5f4: Isolates private browser state and React Query data across authenticated principal transitions.
8
+ - Updated dependencies [4b85404]
9
+ - Updated dependencies [102c5f4]
10
+ - @shipfox/api-auth-dto@9.0.2
11
+ - @shipfox/api-workspaces-dto@9.0.2
12
+ - @shipfox/react-ui@0.3.7
13
+ - @shipfox/client-ui@6.0.2
14
+ - @shipfox/client-shell@6.0.2
15
+ - @shipfox/client-invitations@6.0.2
16
+
17
+ ## 6.0.1
18
+
19
+ ### Patch Changes
20
+
21
+ - 475ce59: Republishes all public packages after restoring release authorization.
22
+ - 3f8f1cb: Enforces typed route-input and browser-storage boundaries across client features.
23
+ - Updated dependencies [475ce59]
24
+ - Updated dependencies [3f8f1cb]
25
+ - @shipfox/api-auth-dto@9.0.1
26
+ - @shipfox/api-workspaces-dto@9.0.1
27
+ - @shipfox/client-api@6.0.1
28
+ - @shipfox/client-invitations@6.0.1
29
+ - @shipfox/client-shell@6.0.1
30
+ - @shipfox/client-ui@6.0.1
31
+ - @shipfox/react-ui@0.3.6
32
+
33
+ ## 6.0.0
34
+
35
+ ### Minor Changes
36
+
37
+ - cd90c19: Enforces package-owned query policies and explicit cache-operation ownership across client resources.
38
+
39
+ ### Patch Changes
40
+
41
+ - d784a07: Enforces checked client API responses and removes stale transport compatibility helpers.
42
+ - 891e469: Adds a sanitized logout redirect that clears local and server auth state before returning to a safe same-origin destination.
43
+ - c56c124: Converges auth sessions and invitation responses on checked domain boundaries.
44
+ - Updated dependencies [401b583]
45
+ - Updated dependencies [82eda45]
46
+ - Updated dependencies [9c9d266]
47
+ - Updated dependencies [cd90c19]
48
+ - Updated dependencies [24be269]
49
+ - Updated dependencies [c56c124]
50
+ - Updated dependencies [4a6d124]
51
+ - Updated dependencies [c02ac42]
52
+ - @shipfox/client-shell@6.0.0
53
+ - @shipfox/api-workspaces-dto@9.0.0
54
+ - @shipfox/client-api@6.0.0
55
+ - @shipfox/client-invitations@6.0.0
56
+ - @shipfox/api-auth-dto@7.1.0
57
+ - @shipfox/client-ui@6.0.0
58
+ - @shipfox/react-ui@0.3.5
59
+
3
60
  ## 5.0.0
4
61
 
5
62
  ### Major Changes
@@ -1 +1 @@
1
- {"version":3,"file":"auth-guard.d.ts","sourceRoot":"","sources":["../../src/components/auth-guard.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAKxD,wBAAgB,SAAS,CAAC,EAAC,QAAQ,EAAC,EAAE,iBAAiB,+VAYtD;AAED,wBAAgB,UAAU,CAAC,EAAC,QAAQ,EAAC,EAAE,iBAAiB,+VA0BvD;AAED,wBAAgB,cAAc,CAAC,EAAC,QAAQ,EAAC,EAAE,iBAAiB,+VAQ3D"}
1
+ {"version":3,"file":"auth-guard.d.ts","sourceRoot":"","sources":["../../src/components/auth-guard.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAMxD,wBAAgB,SAAS,CAAC,EAAC,QAAQ,EAAC,EAAE,iBAAiB,+VAYtD;AAED,wBAAgB,UAAU,CAAC,EAAC,QAAQ,EAAC,EAAE,iBAAiB,+VA0BvD;AAED,wBAAgB,cAAc,CAAC,EAAC,QAAQ,EAAC,EAAE,iBAAiB,+VAQ3D"}
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRouteSearch } from '@shipfox/client-shell/runtime';
2
3
  import { FullPageLoader } from '@shipfox/react-ui/loader';
3
- import { Navigate, useRouter, useSearch } from '@tanstack/react-router';
4
+ import { Navigate, useRouter } from '@tanstack/react-router';
4
5
  import { useEffect } from 'react';
5
6
  import { useAuthState } from '#hooks/use-auth-state.js';
6
7
  import { WorkspaceOnboardingPage } from '#pages/workspace-onboarding-page.js';
8
+ import { validateRedirectSearch } from '../routes/inputs.js';
7
9
  import { sanitizeRedirectPath } from './redirect-target.js';
8
10
  export function AuthGuard({ children }) {
9
11
  const auth = useAuthState();
@@ -20,9 +22,7 @@ export function AuthGuard({ children }) {
20
22
  }
21
23
  export function GuestGuard({ children }) {
22
24
  const auth = useAuthState();
23
- const search = useSearch({
24
- strict: false
25
- });
25
+ const search = useRouteSearch(validateRedirectSearch);
26
26
  const router = useRouter();
27
27
  const target = sanitizeRedirectPath(search.redirect);
28
28
  useEffect(()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/auth-guard.tsx"],"sourcesContent":["import {FullPageLoader} from '@shipfox/react-ui/loader';\nimport {Navigate, useRouter, useSearch} from '@tanstack/react-router';\nimport {type PropsWithChildren, useEffect} from 'react';\nimport {useAuthState} from '#hooks/use-auth-state.js';\nimport {WorkspaceOnboardingPage} from '#pages/workspace-onboarding-page.js';\nimport {sanitizeRedirectPath} from './redirect-target.js';\n\nexport function AuthGuard({children}: PropsWithChildren) {\n const auth = useAuthState();\n\n if (auth.isLoading) {\n return <FullPageLoader />;\n }\n\n if (!auth.isAuthenticated) {\n return <Navigate to=\"/auth/login\" replace />;\n }\n\n return children;\n}\n\nexport function GuestGuard({children}: PropsWithChildren) {\n const auth = useAuthState();\n const search = useSearch({strict: false}) as {redirect?: unknown};\n const router = useRouter();\n const target = sanitizeRedirectPath(search.redirect);\n\n useEffect(() => {\n if (auth.isAuthenticated && target !== undefined) {\n // Bypass the typed route matcher — `target` is an arbitrary same-origin\n // path resolved at runtime, so we let the URL change drive route resolution.\n router.history.replace(target);\n }\n }, [auth.isAuthenticated, target, router]);\n\n if (auth.isLoading) {\n return <FullPageLoader />;\n }\n\n if (auth.isAuthenticated) {\n if (target !== undefined) {\n return <FullPageLoader />;\n }\n return <Navigate to=\"/\" replace />;\n }\n\n return children;\n}\n\nexport function WorkspaceGuard({children}: PropsWithChildren) {\n const auth = useAuthState();\n\n if (auth.isAuthenticated && !auth.hasWorkspace) {\n return <WorkspaceOnboardingPage />;\n }\n\n return children;\n}\n"],"names":["FullPageLoader","Navigate","useRouter","useSearch","useEffect","useAuthState","WorkspaceOnboardingPage","sanitizeRedirectPath","AuthGuard","children","auth","isLoading","isAuthenticated","to","replace","GuestGuard","search","strict","router","target","redirect","undefined","history","WorkspaceGuard","hasWorkspace"],"mappings":";AAAA,SAAQA,cAAc,QAAO,2BAA2B;AACxD,SAAQC,QAAQ,EAAEC,SAAS,EAAEC,SAAS,QAAO,yBAAyB;AACtE,SAAgCC,SAAS,QAAO,QAAQ;AACxD,SAAQC,YAAY,QAAO,2BAA2B;AACtD,SAAQC,uBAAuB,QAAO,sCAAsC;AAC5E,SAAQC,oBAAoB,QAAO,uBAAuB;AAE1D,OAAO,SAASC,UAAU,EAACC,QAAQ,EAAoB;IACrD,MAAMC,OAAOL;IAEb,IAAIK,KAAKC,SAAS,EAAE;QAClB,qBAAO,KAACX;IACV;IAEA,IAAI,CAACU,KAAKE,eAAe,EAAE;QACzB,qBAAO,KAACX;YAASY,IAAG;YAAcC,OAAO;;IAC3C;IAEA,OAAOL;AACT;AAEA,OAAO,SAASM,WAAW,EAACN,QAAQ,EAAoB;IACtD,MAAMC,OAAOL;IACb,MAAMW,SAASb,UAAU;QAACc,QAAQ;IAAK;IACvC,MAAMC,SAAShB;IACf,MAAMiB,SAASZ,qBAAqBS,OAAOI,QAAQ;IAEnDhB,UAAU;QACR,IAAIM,KAAKE,eAAe,IAAIO,WAAWE,WAAW;YAChD,wEAAwE;YACxE,6EAA6E;YAC7EH,OAAOI,OAAO,CAACR,OAAO,CAACK;QACzB;IACF,GAAG;QAACT,KAAKE,eAAe;QAAEO;QAAQD;KAAO;IAEzC,IAAIR,KAAKC,SAAS,EAAE;QAClB,qBAAO,KAACX;IACV;IAEA,IAAIU,KAAKE,eAAe,EAAE;QACxB,IAAIO,WAAWE,WAAW;YACxB,qBAAO,KAACrB;QACV;QACA,qBAAO,KAACC;YAASY,IAAG;YAAIC,OAAO;;IACjC;IAEA,OAAOL;AACT;AAEA,OAAO,SAASc,eAAe,EAACd,QAAQ,EAAoB;IAC1D,MAAMC,OAAOL;IAEb,IAAIK,KAAKE,eAAe,IAAI,CAACF,KAAKc,YAAY,EAAE;QAC9C,qBAAO,KAAClB;IACV;IAEA,OAAOG;AACT"}
1
+ {"version":3,"sources":["../../src/components/auth-guard.tsx"],"sourcesContent":["import {useRouteSearch} from '@shipfox/client-shell/runtime';\nimport {FullPageLoader} from '@shipfox/react-ui/loader';\nimport {Navigate, useRouter} from '@tanstack/react-router';\nimport {type PropsWithChildren, useEffect} from 'react';\nimport {useAuthState} from '#hooks/use-auth-state.js';\nimport {WorkspaceOnboardingPage} from '#pages/workspace-onboarding-page.js';\nimport {validateRedirectSearch} from '../routes/inputs.js';\nimport {sanitizeRedirectPath} from './redirect-target.js';\n\nexport function AuthGuard({children}: PropsWithChildren) {\n const auth = useAuthState();\n\n if (auth.isLoading) {\n return <FullPageLoader />;\n }\n\n if (!auth.isAuthenticated) {\n return <Navigate to=\"/auth/login\" replace />;\n }\n\n return children;\n}\n\nexport function GuestGuard({children}: PropsWithChildren) {\n const auth = useAuthState();\n const search = useRouteSearch(validateRedirectSearch);\n const router = useRouter();\n const target = sanitizeRedirectPath(search.redirect);\n\n useEffect(() => {\n if (auth.isAuthenticated && target !== undefined) {\n // Bypass the typed route matcher — `target` is an arbitrary same-origin\n // path resolved at runtime, so we let the URL change drive route resolution.\n router.history.replace(target);\n }\n }, [auth.isAuthenticated, target, router]);\n\n if (auth.isLoading) {\n return <FullPageLoader />;\n }\n\n if (auth.isAuthenticated) {\n if (target !== undefined) {\n return <FullPageLoader />;\n }\n return <Navigate to=\"/\" replace />;\n }\n\n return children;\n}\n\nexport function WorkspaceGuard({children}: PropsWithChildren) {\n const auth = useAuthState();\n\n if (auth.isAuthenticated && !auth.hasWorkspace) {\n return <WorkspaceOnboardingPage />;\n }\n\n return children;\n}\n"],"names":["useRouteSearch","FullPageLoader","Navigate","useRouter","useEffect","useAuthState","WorkspaceOnboardingPage","validateRedirectSearch","sanitizeRedirectPath","AuthGuard","children","auth","isLoading","isAuthenticated","to","replace","GuestGuard","search","router","target","redirect","undefined","history","WorkspaceGuard","hasWorkspace"],"mappings":";AAAA,SAAQA,cAAc,QAAO,gCAAgC;AAC7D,SAAQC,cAAc,QAAO,2BAA2B;AACxD,SAAQC,QAAQ,EAAEC,SAAS,QAAO,yBAAyB;AAC3D,SAAgCC,SAAS,QAAO,QAAQ;AACxD,SAAQC,YAAY,QAAO,2BAA2B;AACtD,SAAQC,uBAAuB,QAAO,sCAAsC;AAC5E,SAAQC,sBAAsB,QAAO,sBAAsB;AAC3D,SAAQC,oBAAoB,QAAO,uBAAuB;AAE1D,OAAO,SAASC,UAAU,EAACC,QAAQ,EAAoB;IACrD,MAAMC,OAAON;IAEb,IAAIM,KAAKC,SAAS,EAAE;QAClB,qBAAO,KAACX;IACV;IAEA,IAAI,CAACU,KAAKE,eAAe,EAAE;QACzB,qBAAO,KAACX;YAASY,IAAG;YAAcC,OAAO;;IAC3C;IAEA,OAAOL;AACT;AAEA,OAAO,SAASM,WAAW,EAACN,QAAQ,EAAoB;IACtD,MAAMC,OAAON;IACb,MAAMY,SAASjB,eAAeO;IAC9B,MAAMW,SAASf;IACf,MAAMgB,SAASX,qBAAqBS,OAAOG,QAAQ;IAEnDhB,UAAU;QACR,IAAIO,KAAKE,eAAe,IAAIM,WAAWE,WAAW;YAChD,wEAAwE;YACxE,6EAA6E;YAC7EH,OAAOI,OAAO,CAACP,OAAO,CAACI;QACzB;IACF,GAAG;QAACR,KAAKE,eAAe;QAAEM;QAAQD;KAAO;IAEzC,IAAIP,KAAKC,SAAS,EAAE;QAClB,qBAAO,KAACX;IACV;IAEA,IAAIU,KAAKE,eAAe,EAAE;QACxB,IAAIM,WAAWE,WAAW;YACxB,qBAAO,KAACpB;QACV;QACA,qBAAO,KAACC;YAASY,IAAG;YAAIC,OAAO;;IACjC;IAEA,OAAOL;AACT;AAEA,OAAO,SAASa,eAAe,EAACb,QAAQ,EAAoB;IAC1D,MAAMC,OAAON;IAEb,IAAIM,KAAKE,eAAe,IAAI,CAACF,KAAKa,YAAY,EAAE;QAC9C,qBAAO,KAAClB;IACV;IAEA,OAAOI;AACT"}
@@ -1,2 +1,9 @@
1
1
  export declare function sanitizeRedirectPath(value: unknown): string | undefined;
2
+ /**
3
+ * Returns the destination used by the shared logout route.
4
+ *
5
+ * Login is the only auth destination allowed, and invitation tokens never
6
+ * survive this boundary. Invalid values fail closed to login.
7
+ */
8
+ export declare function sanitizeLogoutRedirectPath(value: unknown): string;
2
9
  //# sourceMappingURL=redirect-target.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"redirect-target.d.ts","sourceRoot":"","sources":["../../src/components/redirect-target.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAiBvE"}
1
+ {"version":3,"file":"redirect-target.d.ts","sourceRoot":"","sources":["../../src/components/redirect-target.ts"],"names":[],"mappings":"AAkCA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAIvE;AAOD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOjE"}
@@ -1,7 +1,9 @@
1
1
  const REDIRECT_ORIGIN = 'https://shipfox-redirect.invalid';
2
- // Resolves and canonicalizes an internal path before returning it, so browser URL
3
- // parsing cannot turn a seemingly safe path into an external or auth route.
4
- export function sanitizeRedirectPath(value) {
2
+ const LOGIN_PATH = '/auth/login';
3
+ const INVITATION_ACCEPT_PATH = '/invitations/accept';
4
+ const DEFAULT_LOGOUT_REDIRECT = LOGIN_PATH;
5
+ const TRAILING_SLASHES = /\/+$/;
6
+ function resolveRedirectPath(value) {
5
7
  if (typeof value !== 'string' || !value.startsWith('/')) return undefined;
6
8
  let decoded;
7
9
  try {
@@ -16,8 +18,37 @@ export function sanitizeRedirectPath(value) {
16
18
  return undefined;
17
19
  }
18
20
  if (target.origin !== REDIRECT_ORIGIN) return undefined;
19
- if (target.pathname === '/auth' || target.pathname.startsWith('/auth/')) return undefined;
21
+ return target;
22
+ }
23
+ function formatRedirectPath(target) {
20
24
  return `${target.pathname}${target.search}${target.hash}`;
21
25
  }
26
+ function isAuthPath(pathname) {
27
+ return pathname === '/auth' || pathname.startsWith('/auth/');
28
+ }
29
+ // Resolves and canonicalizes an internal path before returning it, so browser URL
30
+ // parsing cannot turn a seemingly safe path into an external or auth route.
31
+ export function sanitizeRedirectPath(value) {
32
+ const target = resolveRedirectPath(value);
33
+ if (!target || isAuthPath(target.pathname)) return undefined;
34
+ return formatRedirectPath(target);
35
+ }
36
+ function containsInvitationToken(target) {
37
+ const normalizedPathname = target.pathname.replace(TRAILING_SLASHES, '') || '/';
38
+ return normalizedPathname === INVITATION_ACCEPT_PATH && target.searchParams.has('token');
39
+ }
40
+ /**
41
+ * Returns the destination used by the shared logout route.
42
+ *
43
+ * Login is the only auth destination allowed, and invitation tokens never
44
+ * survive this boundary. Invalid values fail closed to login.
45
+ */ export function sanitizeLogoutRedirectPath(value) {
46
+ const target = resolveRedirectPath(value);
47
+ if (!target) return DEFAULT_LOGOUT_REDIRECT;
48
+ if (isAuthPath(target.pathname) || containsInvitationToken(target)) {
49
+ return DEFAULT_LOGOUT_REDIRECT;
50
+ }
51
+ return formatRedirectPath(target);
52
+ }
22
53
 
23
54
  //# sourceMappingURL=redirect-target.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/redirect-target.ts"],"sourcesContent":["const REDIRECT_ORIGIN = 'https://shipfox-redirect.invalid';\n\n// Resolves and canonicalizes an internal path before returning it, so browser URL\n// parsing cannot turn a seemingly safe path into an external or auth route.\nexport function sanitizeRedirectPath(value: unknown): string | undefined {\n if (typeof value !== 'string' || !value.startsWith('/')) return undefined;\n let decoded: string;\n try {\n decoded = decodeURIComponent(value);\n } catch {\n return undefined;\n }\n let target: URL;\n try {\n target = new URL(decoded, REDIRECT_ORIGIN);\n } catch {\n return undefined;\n }\n if (target.origin !== REDIRECT_ORIGIN) return undefined;\n if (target.pathname === '/auth' || target.pathname.startsWith('/auth/')) return undefined;\n return `${target.pathname}${target.search}${target.hash}`;\n}\n"],"names":["REDIRECT_ORIGIN","sanitizeRedirectPath","value","startsWith","undefined","decoded","decodeURIComponent","target","URL","origin","pathname","search","hash"],"mappings":"AAAA,MAAMA,kBAAkB;AAExB,kFAAkF;AAClF,4EAA4E;AAC5E,OAAO,SAASC,qBAAqBC,KAAc;IACjD,IAAI,OAAOA,UAAU,YAAY,CAACA,MAAMC,UAAU,CAAC,MAAM,OAAOC;IAChE,IAAIC;IACJ,IAAI;QACFA,UAAUC,mBAAmBJ;IAC/B,EAAE,OAAM;QACN,OAAOE;IACT;IACA,IAAIG;IACJ,IAAI;QACFA,SAAS,IAAIC,IAAIH,SAASL;IAC5B,EAAE,OAAM;QACN,OAAOI;IACT;IACA,IAAIG,OAAOE,MAAM,KAAKT,iBAAiB,OAAOI;IAC9C,IAAIG,OAAOG,QAAQ,KAAK,WAAWH,OAAOG,QAAQ,CAACP,UAAU,CAAC,WAAW,OAAOC;IAChF,OAAO,GAAGG,OAAOG,QAAQ,GAAGH,OAAOI,MAAM,GAAGJ,OAAOK,IAAI,EAAE;AAC3D"}
1
+ {"version":3,"sources":["../../src/components/redirect-target.ts"],"sourcesContent":["const REDIRECT_ORIGIN = 'https://shipfox-redirect.invalid';\nconst LOGIN_PATH = '/auth/login';\nconst INVITATION_ACCEPT_PATH = '/invitations/accept';\nconst DEFAULT_LOGOUT_REDIRECT = LOGIN_PATH;\nconst TRAILING_SLASHES = /\\/+$/;\n\nfunction resolveRedirectPath(value: unknown): URL | undefined {\n if (typeof value !== 'string' || !value.startsWith('/')) return undefined;\n let decoded: string;\n try {\n decoded = decodeURIComponent(value);\n } catch {\n return undefined;\n }\n let target: URL;\n try {\n target = new URL(decoded, REDIRECT_ORIGIN);\n } catch {\n return undefined;\n }\n if (target.origin !== REDIRECT_ORIGIN) return undefined;\n return target;\n}\n\nfunction formatRedirectPath(target: URL): string {\n return `${target.pathname}${target.search}${target.hash}`;\n}\n\nfunction isAuthPath(pathname: string): boolean {\n return pathname === '/auth' || pathname.startsWith('/auth/');\n}\n\n// Resolves and canonicalizes an internal path before returning it, so browser URL\n// parsing cannot turn a seemingly safe path into an external or auth route.\nexport function sanitizeRedirectPath(value: unknown): string | undefined {\n const target = resolveRedirectPath(value);\n if (!target || isAuthPath(target.pathname)) return undefined;\n return formatRedirectPath(target);\n}\n\nfunction containsInvitationToken(target: URL): boolean {\n const normalizedPathname = target.pathname.replace(TRAILING_SLASHES, '') || '/';\n return normalizedPathname === INVITATION_ACCEPT_PATH && target.searchParams.has('token');\n}\n\n/**\n * Returns the destination used by the shared logout route.\n *\n * Login is the only auth destination allowed, and invitation tokens never\n * survive this boundary. Invalid values fail closed to login.\n */\nexport function sanitizeLogoutRedirectPath(value: unknown): string {\n const target = resolveRedirectPath(value);\n if (!target) return DEFAULT_LOGOUT_REDIRECT;\n if (isAuthPath(target.pathname) || containsInvitationToken(target)) {\n return DEFAULT_LOGOUT_REDIRECT;\n }\n return formatRedirectPath(target);\n}\n"],"names":["REDIRECT_ORIGIN","LOGIN_PATH","INVITATION_ACCEPT_PATH","DEFAULT_LOGOUT_REDIRECT","TRAILING_SLASHES","resolveRedirectPath","value","startsWith","undefined","decoded","decodeURIComponent","target","URL","origin","formatRedirectPath","pathname","search","hash","isAuthPath","sanitizeRedirectPath","containsInvitationToken","normalizedPathname","replace","searchParams","has","sanitizeLogoutRedirectPath"],"mappings":"AAAA,MAAMA,kBAAkB;AACxB,MAAMC,aAAa;AACnB,MAAMC,yBAAyB;AAC/B,MAAMC,0BAA0BF;AAChC,MAAMG,mBAAmB;AAEzB,SAASC,oBAAoBC,KAAc;IACzC,IAAI,OAAOA,UAAU,YAAY,CAACA,MAAMC,UAAU,CAAC,MAAM,OAAOC;IAChE,IAAIC;IACJ,IAAI;QACFA,UAAUC,mBAAmBJ;IAC/B,EAAE,OAAM;QACN,OAAOE;IACT;IACA,IAAIG;IACJ,IAAI;QACFA,SAAS,IAAIC,IAAIH,SAAST;IAC5B,EAAE,OAAM;QACN,OAAOQ;IACT;IACA,IAAIG,OAAOE,MAAM,KAAKb,iBAAiB,OAAOQ;IAC9C,OAAOG;AACT;AAEA,SAASG,mBAAmBH,MAAW;IACrC,OAAO,GAAGA,OAAOI,QAAQ,GAAGJ,OAAOK,MAAM,GAAGL,OAAOM,IAAI,EAAE;AAC3D;AAEA,SAASC,WAAWH,QAAgB;IAClC,OAAOA,aAAa,WAAWA,SAASR,UAAU,CAAC;AACrD;AAEA,kFAAkF;AAClF,4EAA4E;AAC5E,OAAO,SAASY,qBAAqBb,KAAc;IACjD,MAAMK,SAASN,oBAAoBC;IACnC,IAAI,CAACK,UAAUO,WAAWP,OAAOI,QAAQ,GAAG,OAAOP;IACnD,OAAOM,mBAAmBH;AAC5B;AAEA,SAASS,wBAAwBT,MAAW;IAC1C,MAAMU,qBAAqBV,OAAOI,QAAQ,CAACO,OAAO,CAAClB,kBAAkB,OAAO;IAC5E,OAAOiB,uBAAuBnB,0BAA0BS,OAAOY,YAAY,CAACC,GAAG,CAAC;AAClF;AAEA;;;;;CAKC,GACD,OAAO,SAASC,2BAA2BnB,KAAc;IACvD,MAAMK,SAASN,oBAAoBC;IACnC,IAAI,CAACK,QAAQ,OAAOR;IACpB,IAAIe,WAAWP,OAAOI,QAAQ,KAAKK,wBAAwBT,SAAS;QAClE,OAAOR;IACT;IACA,OAAOW,mBAAmBH;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-switcher.d.ts","sourceRoot":"","sources":["../../src/components/workspace-switcher.tsx"],"names":[],"mappings":"AAeA,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,EAAC,iBAAiB,EAAE,QAAQ,EAAC,EAAE,sBAAsB,+BAuDtF"}
1
+ {"version":3,"file":"workspace-switcher.d.ts","sourceRoot":"","sources":["../../src/components/workspace-switcher.tsx"],"names":[],"mappings":"AAeA,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,EAAC,iBAAiB,EAAE,QAAQ,EAAC,EAAE,sBAAsB,+BAwDtF"}
@@ -4,14 +4,15 @@ import { Icon } from '@shipfox/react-ui/icon';
4
4
  import { useNavigate } from '@tanstack/react-router';
5
5
  import { useSetAtom } from 'jotai';
6
6
  import { useAuthState } from '#hooks/use-auth-state.js';
7
- import { lastWorkspaceIdAtom } from '#state/last-workspace.js';
7
+ import { lastWorkspaceIdAtom, rememberLastWorkspaceId } from '#state/last-workspace.js';
8
8
  export function WorkspaceSwitcher({ activeWorkspaceId, onSelect }) {
9
- const { workspaces } = useAuthState();
9
+ const { user, workspaces } = useAuthState();
10
10
  const navigate = useNavigate();
11
11
  const setLastWorkspaceId = useSetAtom(lastWorkspaceIdAtom);
12
12
  const handleSelect = (workspaceId)=>{
13
13
  try {
14
14
  setLastWorkspaceId(workspaceId);
15
+ if (user?.id) rememberLastWorkspaceId(user.id, workspaceId);
15
16
  } catch {
16
17
  // localStorage may throw in private browsing or quota-exceeded; persistence is best-effort.
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/workspace-switcher.tsx"],"sourcesContent":["import {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n} from '@shipfox/react-ui/command';\nimport {Icon} from '@shipfox/react-ui/icon';\nimport {useNavigate} from '@tanstack/react-router';\nimport {useSetAtom} from 'jotai';\nimport {useAuthState} from '#hooks/use-auth-state.js';\nimport {lastWorkspaceIdAtom} from '#state/last-workspace.js';\n\nexport interface WorkspaceSwitcherProps {\n activeWorkspaceId: string | undefined;\n onSelect?: () => void;\n}\n\nexport function WorkspaceSwitcher({activeWorkspaceId, onSelect}: WorkspaceSwitcherProps) {\n const {workspaces} = useAuthState();\n const navigate = useNavigate();\n const setLastWorkspaceId = useSetAtom(lastWorkspaceIdAtom);\n\n const handleSelect = (workspaceId: string) => {\n try {\n setLastWorkspaceId(workspaceId);\n } catch {\n // localStorage may throw in private browsing or quota-exceeded; persistence is best-effort.\n }\n navigate({to: '/workspaces/$wid', params: {wid: workspaceId}});\n onSelect?.();\n };\n\n const handleCreate = () => {\n navigate({to: '/setup/workspaces/new'});\n onSelect?.();\n };\n\n return (\n <Command>\n <CommandInput placeholder=\"Search workspaces...\" />\n <CommandList className=\"max-h-none overflow-visible overflow-y-visible p-0\">\n <div className=\"max-h-300 overflow-y-auto overflow-x-hidden p-4 scrollbar\">\n <CommandEmpty>No workspaces found.</CommandEmpty>\n <CommandGroup heading=\"Workspaces\">\n {workspaces.map((workspace) => (\n <CommandItem\n key={workspace.id}\n value={workspace.id}\n keywords={[workspace.name]}\n onSelect={() => handleSelect(workspace.id)}\n >\n <Icon\n name=\"check\"\n className={`size-16 mr-8 ${\n activeWorkspaceId === workspace.id ? 'opacity-100' : 'opacity-0'\n }`}\n />\n {workspace.name}\n </CommandItem>\n ))}\n </CommandGroup>\n </div>\n <CommandSeparator alwaysRender className=\"mx-0\" />\n <CommandGroup forceMount className=\"p-4\">\n <CommandItem value=\"__create\" onSelect={handleCreate} forceMount>\n <Icon name=\"addLine\" className=\"size-16\" />\n Create workspace\n </CommandItem>\n </CommandGroup>\n </CommandList>\n </Command>\n );\n}\n"],"names":["Command","CommandEmpty","CommandGroup","CommandInput","CommandItem","CommandList","CommandSeparator","Icon","useNavigate","useSetAtom","useAuthState","lastWorkspaceIdAtom","WorkspaceSwitcher","activeWorkspaceId","onSelect","workspaces","navigate","setLastWorkspaceId","handleSelect","workspaceId","to","params","wid","handleCreate","placeholder","className","div","heading","map","workspace","value","id","keywords","name","alwaysRender","forceMount"],"mappings":";AAAA,SACEA,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,gBAAgB,QACX,4BAA4B;AACnC,SAAQC,IAAI,QAAO,yBAAyB;AAC5C,SAAQC,WAAW,QAAO,yBAAyB;AACnD,SAAQC,UAAU,QAAO,QAAQ;AACjC,SAAQC,YAAY,QAAO,2BAA2B;AACtD,SAAQC,mBAAmB,QAAO,2BAA2B;AAO7D,OAAO,SAASC,kBAAkB,EAACC,iBAAiB,EAAEC,QAAQ,EAAyB;IACrF,MAAM,EAACC,UAAU,EAAC,GAAGL;IACrB,MAAMM,WAAWR;IACjB,MAAMS,qBAAqBR,WAAWE;IAEtC,MAAMO,eAAe,CAACC;QACpB,IAAI;YACFF,mBAAmBE;QACrB,EAAE,OAAM;QACN,4FAA4F;QAC9F;QACAH,SAAS;YAACI,IAAI;YAAoBC,QAAQ;gBAACC,KAAKH;YAAW;QAAC;QAC5DL;IACF;IAEA,MAAMS,eAAe;QACnBP,SAAS;YAACI,IAAI;QAAuB;QACrCN;IACF;IAEA,qBACE,MAACd;;0BACC,KAACG;gBAAaqB,aAAY;;0BAC1B,MAACnB;gBAAYoB,WAAU;;kCACrB,MAACC;wBAAID,WAAU;;0CACb,KAACxB;0CAAa;;0CACd,KAACC;gCAAayB,SAAQ;0CACnBZ,WAAWa,GAAG,CAAC,CAACC,0BACf,MAACzB;wCAEC0B,OAAOD,UAAUE,EAAE;wCACnBC,UAAU;4CAACH,UAAUI,IAAI;yCAAC;wCAC1BnB,UAAU,IAAMI,aAAaW,UAAUE,EAAE;;0DAEzC,KAACxB;gDACC0B,MAAK;gDACLR,WAAW,CAAC,aAAa,EACvBZ,sBAAsBgB,UAAUE,EAAE,GAAG,gBAAgB,aACrD;;4CAEHF,UAAUI,IAAI;;uCAXVJ,UAAUE,EAAE;;;;kCAgBzB,KAACzB;wBAAiB4B,YAAY;wBAACT,WAAU;;kCACzC,KAACvB;wBAAaiC,UAAU;wBAACV,WAAU;kCACjC,cAAA,MAACrB;4BAAY0B,OAAM;4BAAWhB,UAAUS;4BAAcY,UAAU;;8CAC9D,KAAC5B;oCAAK0B,MAAK;oCAAUR,WAAU;;gCAAY;;;;;;;;AAOvD"}
1
+ {"version":3,"sources":["../../src/components/workspace-switcher.tsx"],"sourcesContent":["import {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n} from '@shipfox/react-ui/command';\nimport {Icon} from '@shipfox/react-ui/icon';\nimport {useNavigate} from '@tanstack/react-router';\nimport {useSetAtom} from 'jotai';\nimport {useAuthState} from '#hooks/use-auth-state.js';\nimport {lastWorkspaceIdAtom, rememberLastWorkspaceId} from '#state/last-workspace.js';\n\nexport interface WorkspaceSwitcherProps {\n activeWorkspaceId: string | undefined;\n onSelect?: () => void;\n}\n\nexport function WorkspaceSwitcher({activeWorkspaceId, onSelect}: WorkspaceSwitcherProps) {\n const {user, workspaces} = useAuthState();\n const navigate = useNavigate();\n const setLastWorkspaceId = useSetAtom(lastWorkspaceIdAtom);\n\n const handleSelect = (workspaceId: string) => {\n try {\n setLastWorkspaceId(workspaceId);\n if (user?.id) rememberLastWorkspaceId(user.id, workspaceId);\n } catch {\n // localStorage may throw in private browsing or quota-exceeded; persistence is best-effort.\n }\n navigate({to: '/workspaces/$wid', params: {wid: workspaceId}});\n onSelect?.();\n };\n\n const handleCreate = () => {\n navigate({to: '/setup/workspaces/new'});\n onSelect?.();\n };\n\n return (\n <Command>\n <CommandInput placeholder=\"Search workspaces...\" />\n <CommandList className=\"max-h-none overflow-visible overflow-y-visible p-0\">\n <div className=\"max-h-300 overflow-y-auto overflow-x-hidden p-4 scrollbar\">\n <CommandEmpty>No workspaces found.</CommandEmpty>\n <CommandGroup heading=\"Workspaces\">\n {workspaces.map((workspace) => (\n <CommandItem\n key={workspace.id}\n value={workspace.id}\n keywords={[workspace.name]}\n onSelect={() => handleSelect(workspace.id)}\n >\n <Icon\n name=\"check\"\n className={`size-16 mr-8 ${\n activeWorkspaceId === workspace.id ? 'opacity-100' : 'opacity-0'\n }`}\n />\n {workspace.name}\n </CommandItem>\n ))}\n </CommandGroup>\n </div>\n <CommandSeparator alwaysRender className=\"mx-0\" />\n <CommandGroup forceMount className=\"p-4\">\n <CommandItem value=\"__create\" onSelect={handleCreate} forceMount>\n <Icon name=\"addLine\" className=\"size-16\" />\n Create workspace\n </CommandItem>\n </CommandGroup>\n </CommandList>\n </Command>\n );\n}\n"],"names":["Command","CommandEmpty","CommandGroup","CommandInput","CommandItem","CommandList","CommandSeparator","Icon","useNavigate","useSetAtom","useAuthState","lastWorkspaceIdAtom","rememberLastWorkspaceId","WorkspaceSwitcher","activeWorkspaceId","onSelect","user","workspaces","navigate","setLastWorkspaceId","handleSelect","workspaceId","id","to","params","wid","handleCreate","placeholder","className","div","heading","map","workspace","value","keywords","name","alwaysRender","forceMount"],"mappings":";AAAA,SACEA,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,gBAAgB,QACX,4BAA4B;AACnC,SAAQC,IAAI,QAAO,yBAAyB;AAC5C,SAAQC,WAAW,QAAO,yBAAyB;AACnD,SAAQC,UAAU,QAAO,QAAQ;AACjC,SAAQC,YAAY,QAAO,2BAA2B;AACtD,SAAQC,mBAAmB,EAAEC,uBAAuB,QAAO,2BAA2B;AAOtF,OAAO,SAASC,kBAAkB,EAACC,iBAAiB,EAAEC,QAAQ,EAAyB;IACrF,MAAM,EAACC,IAAI,EAAEC,UAAU,EAAC,GAAGP;IAC3B,MAAMQ,WAAWV;IACjB,MAAMW,qBAAqBV,WAAWE;IAEtC,MAAMS,eAAe,CAACC;QACpB,IAAI;YACFF,mBAAmBE;YACnB,IAAIL,MAAMM,IAAIV,wBAAwBI,KAAKM,EAAE,EAAED;QACjD,EAAE,OAAM;QACN,4FAA4F;QAC9F;QACAH,SAAS;YAACK,IAAI;YAAoBC,QAAQ;gBAACC,KAAKJ;YAAW;QAAC;QAC5DN;IACF;IAEA,MAAMW,eAAe;QACnBR,SAAS;YAACK,IAAI;QAAuB;QACrCR;IACF;IAEA,qBACE,MAACf;;0BACC,KAACG;gBAAawB,aAAY;;0BAC1B,MAACtB;gBAAYuB,WAAU;;kCACrB,MAACC;wBAAID,WAAU;;0CACb,KAAC3B;0CAAa;;0CACd,KAACC;gCAAa4B,SAAQ;0CACnBb,WAAWc,GAAG,CAAC,CAACC,0BACf,MAAC5B;wCAEC6B,OAAOD,UAAUV,EAAE;wCACnBY,UAAU;4CAACF,UAAUG,IAAI;yCAAC;wCAC1BpB,UAAU,IAAMK,aAAaY,UAAUV,EAAE;;0DAEzC,KAACf;gDACC4B,MAAK;gDACLP,WAAW,CAAC,aAAa,EACvBd,sBAAsBkB,UAAUV,EAAE,GAAG,gBAAgB,aACrD;;4CAEHU,UAAUG,IAAI;;uCAXVH,UAAUV,EAAE;;;;kCAgBzB,KAAChB;wBAAiB8B,YAAY;wBAACR,WAAU;;kCACzC,KAAC1B;wBAAamC,UAAU;wBAACT,WAAU;kCACjC,cAAA,MAACxB;4BAAY6B,OAAM;4BAAWlB,UAAUW;4BAAcW,UAAU;;8CAC9D,KAAC9B;oCAAK4B,MAAK;oCAAUP,WAAU;;gCAAY;;;;;;;;AAOvD"}
@@ -0,0 +1,57 @@
1
+ export interface LoginCommand {
2
+ email: string;
3
+ password: string;
4
+ }
5
+ export interface SignupCommand extends LoginCommand {
6
+ name: string;
7
+ invitationToken?: string;
8
+ }
9
+ export interface PasswordResetRequestCommand {
10
+ email: string;
11
+ }
12
+ export interface PasswordResetConfirmCommand {
13
+ token: string;
14
+ newPassword: string;
15
+ }
16
+ export interface VerifyEmailCommand {
17
+ email: string;
18
+ challengeId: string;
19
+ code: string;
20
+ }
21
+ export interface ResendEmailVerificationCommand {
22
+ email: string;
23
+ challengeId: string;
24
+ }
25
+ export interface WorkspaceCreateCommand {
26
+ name: string;
27
+ }
28
+ export interface Workspace {
29
+ id: string;
30
+ name: string;
31
+ status: 'active' | 'suspended' | 'deleted';
32
+ }
33
+ export interface SignupResult {
34
+ user: {
35
+ id: string;
36
+ email: string;
37
+ name?: string;
38
+ emailVerifiedAt?: string;
39
+ };
40
+ emailChallenge?: {
41
+ id: string;
42
+ nextResendAvailableAt: string;
43
+ };
44
+ membership?: {
45
+ id: string;
46
+ userId: string;
47
+ workspaceId: string;
48
+ };
49
+ acceptError?: {
50
+ code: string;
51
+ message: string;
52
+ };
53
+ }
54
+ export interface EmailVerificationResendResult {
55
+ nextResendAvailableAt: string;
56
+ }
57
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/core/auth.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,cAAc,CAAC,EAAE;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,qBAAqB,EAAE,MAAM,CAAA;KAAC,CAAC;IAC7D,UAAU,CAAC,EAAE;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC,CAAC;IAC/D,WAAW,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;CAC/C;AAED,MAAM,WAAW,6BAA6B;IAC5C,qBAAqB,EAAE,MAAM,CAAC;CAC/B"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/auth.ts"],"sourcesContent":["export interface LoginCommand {\n email: string;\n password: string;\n}\n\nexport interface SignupCommand extends LoginCommand {\n name: string;\n invitationToken?: string;\n}\n\nexport interface PasswordResetRequestCommand {\n email: string;\n}\n\nexport interface PasswordResetConfirmCommand {\n token: string;\n newPassword: string;\n}\n\nexport interface VerifyEmailCommand {\n email: string;\n challengeId: string;\n code: string;\n}\n\nexport interface ResendEmailVerificationCommand {\n email: string;\n challengeId: string;\n}\n\nexport interface WorkspaceCreateCommand {\n name: string;\n}\n\nexport interface Workspace {\n id: string;\n name: string;\n status: 'active' | 'suspended' | 'deleted';\n}\n\nexport interface SignupResult {\n user: {\n id: string;\n email: string;\n name?: string;\n emailVerifiedAt?: string;\n };\n emailChallenge?: {id: string; nextResendAvailableAt: string};\n membership?: {id: string; userId: string; workspaceId: string};\n acceptError?: {code: string; message: string};\n}\n\nexport interface EmailVerificationResendResult {\n nextResendAvailableAt: string;\n}\n"],"names":[],"mappings":"AAoDA,WAEC"}
@@ -1,21 +1,6 @@
1
1
  import type { SignupResponseDto } from '@shipfox/api-auth-dto';
2
- import { toAuthenticatedSession, type UserIdentity } from '@shipfox/client-shell/runtime';
2
+ import { toAuthenticatedSession } from '@shipfox/client-shell/runtime';
3
+ import type { SignupResult } from '#core/auth.js';
3
4
  export { toAuthenticatedSession };
4
- export interface SignupResult {
5
- user: UserIdentity;
6
- emailChallenge?: {
7
- id: string;
8
- nextResendAvailableAt: string;
9
- };
10
- membership?: {
11
- id: string;
12
- userId: string;
13
- workspaceId: string;
14
- };
15
- acceptError?: {
16
- code: string;
17
- message: string;
18
- };
19
- }
20
5
  export declare function toSignupResult(dto: SignupResponseDto): SignupResult;
21
6
  //# sourceMappingURL=auth-mapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-mapper.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/auth-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,sBAAsB,EAEtB,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,sBAAsB,EAAC,CAAC;AAEhC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,cAAc,CAAC,EAAE;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,qBAAqB,EAAE,MAAM,CAAA;KAAC,CAAC;IAC7D,UAAU,CAAC,EAAE;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC,CAAC;IAC/D,WAAW,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;CAC/C;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,YAAY,CAsBnE"}
1
+ {"version":3,"file":"auth-mapper.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/auth-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAC,sBAAsB,EAAiB,MAAM,+BAA+B,CAAC;AACrF,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAC,sBAAsB,EAAC,CAAC;AAEhC,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,YAAY,CAsBnE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/auth-mapper.ts"],"sourcesContent":["import type {SignupResponseDto} from '@shipfox/api-auth-dto';\nimport {\n toAuthenticatedSession,\n toUserIdentity,\n type UserIdentity,\n} from '@shipfox/client-shell/runtime';\n\nexport {toAuthenticatedSession};\n\nexport interface SignupResult {\n user: UserIdentity;\n emailChallenge?: {id: string; nextResendAvailableAt: string};\n membership?: {id: string; userId: string; workspaceId: string};\n acceptError?: {code: string; message: string};\n}\n\nexport function toSignupResult(dto: SignupResponseDto): SignupResult {\n return {\n user: toUserIdentity(dto.user),\n ...(dto.email_challenge\n ? {\n emailChallenge: {\n id: dto.email_challenge.id,\n nextResendAvailableAt: dto.email_challenge.next_resend_available_at,\n },\n }\n : {}),\n ...(dto.membership\n ? {\n membership: {\n id: dto.membership.id,\n userId: dto.membership.user_id,\n workspaceId: dto.membership.workspace_id,\n },\n }\n : {}),\n ...(dto.accept_error ? {acceptError: dto.accept_error} : {}),\n };\n}\n"],"names":["toAuthenticatedSession","toUserIdentity","toSignupResult","dto","user","email_challenge","emailChallenge","id","nextResendAvailableAt","next_resend_available_at","membership","userId","user_id","workspaceId","workspace_id","accept_error","acceptError"],"mappings":"AACA,SACEA,sBAAsB,EACtBC,cAAc,QAET,gCAAgC;AAEvC,SAAQD,sBAAsB,GAAE;AAShC,OAAO,SAASE,eAAeC,GAAsB;IACnD,OAAO;QACLC,MAAMH,eAAeE,IAAIC,IAAI;QAC7B,GAAID,IAAIE,eAAe,GACnB;YACEC,gBAAgB;gBACdC,IAAIJ,IAAIE,eAAe,CAACE,EAAE;gBAC1BC,uBAAuBL,IAAIE,eAAe,CAACI,wBAAwB;YACrE;QACF,IACA,CAAC,CAAC;QACN,GAAIN,IAAIO,UAAU,GACd;YACEA,YAAY;gBACVH,IAAIJ,IAAIO,UAAU,CAACH,EAAE;gBACrBI,QAAQR,IAAIO,UAAU,CAACE,OAAO;gBAC9BC,aAAaV,IAAIO,UAAU,CAACI,YAAY;YAC1C;QACF,IACA,CAAC,CAAC;QACN,GAAIX,IAAIY,YAAY,GAAG;YAACC,aAAab,IAAIY,YAAY;QAAA,IAAI,CAAC,CAAC;IAC7D;AACF"}
1
+ {"version":3,"sources":["../../../src/hooks/api/auth-mapper.ts"],"sourcesContent":["import type {SignupResponseDto} from '@shipfox/api-auth-dto';\nimport {toAuthenticatedSession, toUserIdentity} from '@shipfox/client-shell/runtime';\nimport type {SignupResult} from '#core/auth.js';\n\nexport {toAuthenticatedSession};\n\nexport function toSignupResult(dto: SignupResponseDto): SignupResult {\n return {\n user: toUserIdentity(dto.user),\n ...(dto.email_challenge\n ? {\n emailChallenge: {\n id: dto.email_challenge.id,\n nextResendAvailableAt: dto.email_challenge.next_resend_available_at,\n },\n }\n : {}),\n ...(dto.membership\n ? {\n membership: {\n id: dto.membership.id,\n userId: dto.membership.user_id,\n workspaceId: dto.membership.workspace_id,\n },\n }\n : {}),\n ...(dto.accept_error ? {acceptError: dto.accept_error} : {}),\n };\n}\n"],"names":["toAuthenticatedSession","toUserIdentity","toSignupResult","dto","user","email_challenge","emailChallenge","id","nextResendAvailableAt","next_resend_available_at","membership","userId","user_id","workspaceId","workspace_id","accept_error","acceptError"],"mappings":"AACA,SAAQA,sBAAsB,EAAEC,cAAc,QAAO,gCAAgC;AAGrF,SAAQD,sBAAsB,GAAE;AAEhC,OAAO,SAASE,eAAeC,GAAsB;IACnD,OAAO;QACLC,MAAMH,eAAeE,IAAIC,IAAI;QAC7B,GAAID,IAAIE,eAAe,GACnB;YACEC,gBAAgB;gBACdC,IAAIJ,IAAIE,eAAe,CAACE,EAAE;gBAC1BC,uBAAuBL,IAAIE,eAAe,CAACI,wBAAwB;YACrE;QACF,IACA,CAAC,CAAC;QACN,GAAIN,IAAIO,UAAU,GACd;YACEA,YAAY;gBACVH,IAAIJ,IAAIO,UAAU,CAACH,EAAE;gBACrBI,QAAQR,IAAIO,UAAU,CAACE,OAAO;gBAC9BC,aAAaV,IAAIO,UAAU,CAACI,YAAY;YAC1C;QACF,IACA,CAAC,CAAC;QACN,GAAIX,IAAIY,YAAY,GAAG;YAACC,aAAab,IAAIY,YAAY;QAAA,IAAI,CAAC,CAAC;IAC7D;AACF"}
@@ -1,7 +1,4 @@
1
- import { type LoginBodyDto } from '@shipfox/api-auth-dto';
2
- export declare function loginAuth(body: LoginBodyDto): Promise<import("@shipfox/client-shell/runtime").AuthenticatedSession>;
3
- export declare function useLoginAuth(): import("@tanstack/react-query").UseMutationResult<import("@shipfox/client-shell/runtime").AuthenticatedSession, Error, {
4
- email: string;
5
- password: string;
6
- }, unknown>;
1
+ import type { LoginCommand } from '#core/auth.js';
2
+ export declare function loginAuth(command: LoginCommand): Promise<import("@shipfox/client-shell/runtime").AuthenticatedSession>;
3
+ export declare function useLoginAuth(): import("@tanstack/react-query").UseMutationResult<import("@shipfox/client-shell/runtime").AuthenticatedSession, Error, LoginCommand, unknown>;
7
4
  //# sourceMappingURL=login-auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/login-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,YAAY,EAAsB,MAAM,uBAAuB,CAAC;AAM7E,wBAAsB,SAAS,CAAC,IAAI,EAAE,YAAY,yEAMjD;AAED,wBAAgB,YAAY;;;YAO3B"}
1
+ {"version":3,"file":"login-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/login-auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAIhD,wBAAsB,SAAS,CAAC,OAAO,EAAE,YAAY,yEAMpD;AAED,wBAAgB,YAAY,kJAO3B"}
@@ -3,10 +3,10 @@ import { checkedApiRequest } from '@shipfox/client-api';
3
3
  import { useMutation } from '@tanstack/react-query';
4
4
  import { useAuthTransition } from '#state/auth.js';
5
5
  import { toAuthenticatedSession } from './auth-mapper.js';
6
- export async function loginAuth(body) {
6
+ export async function loginAuth(command) {
7
7
  const response = await checkedApiRequest(loginResponseSchema, '/auth/login', {
8
8
  method: 'POST',
9
- body
9
+ body: command
10
10
  });
11
11
  return toAuthenticatedSession(response);
12
12
  }
@@ -14,7 +14,7 @@ export function useLoginAuth() {
14
14
  const { enterAuthenticated } = useAuthTransition();
15
15
  return useMutation({
16
16
  mutationFn: loginAuth,
17
- onSuccess: enterAuthenticated
17
+ onSuccess: (session)=>enterAuthenticated(session)
18
18
  });
19
19
  }
20
20
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/login-auth.ts"],"sourcesContent":["import {type LoginBodyDto, loginResponseSchema} from '@shipfox/api-auth-dto';\nimport {checkedApiRequest} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport {useAuthTransition} from '#state/auth.js';\nimport {toAuthenticatedSession} from './auth-mapper.js';\n\nexport async function loginAuth(body: LoginBodyDto) {\n const response = await checkedApiRequest(loginResponseSchema, '/auth/login', {\n method: 'POST',\n body,\n });\n return toAuthenticatedSession(response);\n}\n\nexport function useLoginAuth() {\n const {enterAuthenticated} = useAuthTransition();\n\n return useMutation({\n mutationFn: loginAuth,\n onSuccess: enterAuthenticated,\n });\n}\n"],"names":["loginResponseSchema","checkedApiRequest","useMutation","useAuthTransition","toAuthenticatedSession","loginAuth","body","response","method","useLoginAuth","enterAuthenticated","mutationFn","onSuccess"],"mappings":"AAAA,SAA2BA,mBAAmB,QAAO,wBAAwB;AAC7E,SAAQC,iBAAiB,QAAO,sBAAsB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,iBAAiB,QAAO,iBAAiB;AACjD,SAAQC,sBAAsB,QAAO,mBAAmB;AAExD,OAAO,eAAeC,UAAUC,IAAkB;IAChD,MAAMC,WAAW,MAAMN,kBAAkBD,qBAAqB,eAAe;QAC3EQ,QAAQ;QACRF;IACF;IACA,OAAOF,uBAAuBG;AAChC;AAEA,OAAO,SAASE;IACd,MAAM,EAACC,kBAAkB,EAAC,GAAGP;IAE7B,OAAOD,YAAY;QACjBS,YAAYN;QACZO,WAAWF;IACb;AACF"}
1
+ {"version":3,"sources":["../../../src/hooks/api/login-auth.ts"],"sourcesContent":["import {loginResponseSchema} from '@shipfox/api-auth-dto';\nimport {checkedApiRequest} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport type {LoginCommand} from '#core/auth.js';\nimport {useAuthTransition} from '#state/auth.js';\nimport {toAuthenticatedSession} from './auth-mapper.js';\n\nexport async function loginAuth(command: LoginCommand) {\n const response = await checkedApiRequest(loginResponseSchema, '/auth/login', {\n method: 'POST',\n body: command,\n });\n return toAuthenticatedSession(response);\n}\n\nexport function useLoginAuth() {\n const {enterAuthenticated} = useAuthTransition();\n\n return useMutation({\n mutationFn: loginAuth,\n onSuccess: (session) => enterAuthenticated(session),\n });\n}\n"],"names":["loginResponseSchema","checkedApiRequest","useMutation","useAuthTransition","toAuthenticatedSession","loginAuth","command","response","method","body","useLoginAuth","enterAuthenticated","mutationFn","onSuccess","session"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,wBAAwB;AAC1D,SAAQC,iBAAiB,QAAO,sBAAsB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,iBAAiB,QAAO,iBAAiB;AACjD,SAAQC,sBAAsB,QAAO,mBAAmB;AAExD,OAAO,eAAeC,UAAUC,OAAqB;IACnD,MAAMC,WAAW,MAAMN,kBAAkBD,qBAAqB,eAAe;QAC3EQ,QAAQ;QACRC,MAAMH;IACR;IACA,OAAOF,uBAAuBG;AAChC;AAEA,OAAO,SAASG;IACd,MAAM,EAACC,kBAAkB,EAAC,GAAGR;IAE7B,OAAOD,YAAY;QACjBU,YAAYP;QACZQ,WAAW,CAACC,UAAYH,mBAAmBG;IAC7C;AACF"}
@@ -1,9 +1,9 @@
1
- import { apiRequest } from '@shipfox/client-api';
1
+ import { checkedApiRequest, emptyResponseSchema } from '@shipfox/client-api';
2
2
  import { useMutation } from '@tanstack/react-query';
3
3
  import { useAuthTransition } from '#state/auth.js';
4
4
  async function logoutAuth() {
5
5
  try {
6
- await apiRequest('/auth/logout', {
6
+ await checkedApiRequest(emptyResponseSchema, '/auth/logout', {
7
7
  method: 'POST',
8
8
  body: {}
9
9
  });
@@ -15,7 +15,7 @@ export function useLogoutAuth() {
15
15
  const { enterGuest } = useAuthTransition();
16
16
  return useMutation({
17
17
  mutationFn: logoutAuth,
18
- onSettled: enterGuest
18
+ onSettled: ()=>enterGuest()
19
19
  });
20
20
  }
21
21
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/logout-auth.ts"],"sourcesContent":["import {apiRequest} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport {useAuthTransition} from '#state/auth.js';\n\nasync function logoutAuth() {\n try {\n await apiRequest<void>('/auth/logout', {method: 'POST', body: {}});\n } catch {\n // Logout is best-effort: local session state must clear even if the API is offline.\n }\n}\n\nexport function useLogoutAuth() {\n const {enterGuest} = useAuthTransition();\n\n return useMutation({\n mutationFn: logoutAuth,\n onSettled: enterGuest,\n });\n}\n"],"names":["apiRequest","useMutation","useAuthTransition","logoutAuth","method","body","useLogoutAuth","enterGuest","mutationFn","onSettled"],"mappings":"AAAA,SAAQA,UAAU,QAAO,sBAAsB;AAC/C,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,iBAAiB,QAAO,iBAAiB;AAEjD,eAAeC;IACb,IAAI;QACF,MAAMH,WAAiB,gBAAgB;YAACI,QAAQ;YAAQC,MAAM,CAAC;QAAC;IAClE,EAAE,OAAM;IACN,oFAAoF;IACtF;AACF;AAEA,OAAO,SAASC;IACd,MAAM,EAACC,UAAU,EAAC,GAAGL;IAErB,OAAOD,YAAY;QACjBO,YAAYL;QACZM,WAAWF;IACb;AACF"}
1
+ {"version":3,"sources":["../../../src/hooks/api/logout-auth.ts"],"sourcesContent":["import {checkedApiRequest, emptyResponseSchema} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport {useAuthTransition} from '#state/auth.js';\n\nasync function logoutAuth() {\n try {\n await checkedApiRequest(emptyResponseSchema, '/auth/logout', {method: 'POST', body: {}});\n } catch {\n // Logout is best-effort: local session state must clear even if the API is offline.\n }\n}\n\nexport function useLogoutAuth() {\n const {enterGuest} = useAuthTransition();\n\n return useMutation({\n mutationFn: logoutAuth,\n onSettled: () => enterGuest(),\n });\n}\n"],"names":["checkedApiRequest","emptyResponseSchema","useMutation","useAuthTransition","logoutAuth","method","body","useLogoutAuth","enterGuest","mutationFn","onSettled"],"mappings":"AAAA,SAAQA,iBAAiB,EAAEC,mBAAmB,QAAO,sBAAsB;AAC3E,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,iBAAiB,QAAO,iBAAiB;AAEjD,eAAeC;IACb,IAAI;QACF,MAAMJ,kBAAkBC,qBAAqB,gBAAgB;YAACI,QAAQ;YAAQC,MAAM,CAAC;QAAC;IACxF,EAAE,OAAM;IACN,oFAAoF;IACtF;AACF;AAEA,OAAO,SAASC;IACd,MAAM,EAACC,UAAU,EAAC,GAAGL;IAErB,OAAOD,YAAY;QACjBO,YAAYL;QACZM,WAAW,IAAMF;IACnB;AACF"}
@@ -1,11 +1,6 @@
1
- import { type PasswordResetConfirmBodyDto, type PasswordResetRequestBodyDto } from '@shipfox/api-auth-dto';
2
- export declare function requestPasswordReset(body: PasswordResetRequestBodyDto): Promise<void>;
3
- export declare function confirmPasswordReset(body: PasswordResetConfirmBodyDto): Promise<import("@shipfox/client-shell/runtime").AuthenticatedSession>;
4
- export declare function useRequestPasswordResetAuth(): import("@tanstack/react-query").UseMutationResult<void, Error, {
5
- email: string;
6
- }, unknown>;
7
- export declare function useConfirmPasswordResetAuth(): import("@tanstack/react-query").UseMutationResult<import("@shipfox/client-shell/runtime").AuthenticatedSession, Error, {
8
- token: string;
9
- new_password: string;
10
- }, unknown>;
1
+ import type { PasswordResetConfirmCommand, PasswordResetRequestCommand } from '#core/auth.js';
2
+ export declare function requestPasswordReset(command: PasswordResetRequestCommand): Promise<void>;
3
+ export declare function confirmPasswordReset(command: PasswordResetConfirmCommand): Promise<import("@shipfox/client-shell/runtime").AuthenticatedSession>;
4
+ export declare function useRequestPasswordResetAuth(): import("@tanstack/react-query").UseMutationResult<void, Error, PasswordResetRequestCommand, unknown>;
5
+ export declare function useConfirmPasswordResetAuth(): import("@tanstack/react-query").UseMutationResult<import("@shipfox/client-shell/runtime").AuthenticatedSession, Error, PasswordResetConfirmCommand, unknown>;
11
6
  //# sourceMappingURL=password-reset-auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"password-reset-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/password-reset-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAEjC,MAAM,uBAAuB,CAAC;AAM/B,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,2BAA2B,iBAE3E;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,2BAA2B,yEAU3E;AAED,wBAAgB,2BAA2B;;YAE1C;AAED,wBAAgB,2BAA2B;;;YAO1C"}
1
+ {"version":3,"file":"password-reset-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/password-reset-auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,2BAA2B,EAAE,2BAA2B,EAAC,MAAM,eAAe,CAAC;AAI5F,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,iBAK9E;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,yEAU9E;AAED,wBAAgB,2BAA2B,yGAE1C;AAED,wBAAgB,2BAA2B,iKAO1C"}
@@ -1,18 +1,21 @@
1
1
  import { passwordResetConfirmResponseSchema } from '@shipfox/api-auth-dto';
2
- import { apiRequest, checkedApiRequest } from '@shipfox/client-api';
2
+ import { checkedApiRequest, emptyResponseSchema } from '@shipfox/client-api';
3
3
  import { useMutation } from '@tanstack/react-query';
4
4
  import { useAuthTransition } from '#state/auth.js';
5
5
  import { toAuthenticatedSession } from './auth-mapper.js';
6
- export async function requestPasswordReset(body) {
7
- await apiRequest('/auth/password-reset', {
6
+ export async function requestPasswordReset(command) {
7
+ await checkedApiRequest(emptyResponseSchema, '/auth/password-reset', {
8
8
  method: 'POST',
9
- body
9
+ body: command
10
10
  });
11
11
  }
12
- export async function confirmPasswordReset(body) {
12
+ export async function confirmPasswordReset(command) {
13
13
  const response = await checkedApiRequest(passwordResetConfirmResponseSchema, '/auth/password-reset/confirm', {
14
14
  method: 'POST',
15
- body
15
+ body: {
16
+ token: command.token,
17
+ new_password: command.newPassword
18
+ }
16
19
  });
17
20
  return toAuthenticatedSession(response);
18
21
  }
@@ -25,7 +28,7 @@ export function useConfirmPasswordResetAuth() {
25
28
  const { enterAuthenticated } = useAuthTransition();
26
29
  return useMutation({
27
30
  mutationFn: confirmPasswordReset,
28
- onSuccess: enterAuthenticated
31
+ onSuccess: (session)=>enterAuthenticated(session)
29
32
  });
30
33
  }
31
34
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/password-reset-auth.ts"],"sourcesContent":["import {\n type PasswordResetConfirmBodyDto,\n type PasswordResetRequestBodyDto,\n passwordResetConfirmResponseSchema,\n} from '@shipfox/api-auth-dto';\nimport {apiRequest, checkedApiRequest} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport {useAuthTransition} from '#state/auth.js';\nimport {toAuthenticatedSession} from './auth-mapper.js';\n\nexport async function requestPasswordReset(body: PasswordResetRequestBodyDto) {\n await apiRequest<void>('/auth/password-reset', {method: 'POST', body});\n}\n\nexport async function confirmPasswordReset(body: PasswordResetConfirmBodyDto) {\n const response = await checkedApiRequest(\n passwordResetConfirmResponseSchema,\n '/auth/password-reset/confirm',\n {\n method: 'POST',\n body,\n },\n );\n return toAuthenticatedSession(response);\n}\n\nexport function useRequestPasswordResetAuth() {\n return useMutation({mutationFn: requestPasswordReset});\n}\n\nexport function useConfirmPasswordResetAuth() {\n const {enterAuthenticated} = useAuthTransition();\n\n return useMutation({\n mutationFn: confirmPasswordReset,\n onSuccess: enterAuthenticated,\n });\n}\n"],"names":["passwordResetConfirmResponseSchema","apiRequest","checkedApiRequest","useMutation","useAuthTransition","toAuthenticatedSession","requestPasswordReset","body","method","confirmPasswordReset","response","useRequestPasswordResetAuth","mutationFn","useConfirmPasswordResetAuth","enterAuthenticated","onSuccess"],"mappings":"AAAA,SAGEA,kCAAkC,QAC7B,wBAAwB;AAC/B,SAAQC,UAAU,EAAEC,iBAAiB,QAAO,sBAAsB;AAClE,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,iBAAiB,QAAO,iBAAiB;AACjD,SAAQC,sBAAsB,QAAO,mBAAmB;AAExD,OAAO,eAAeC,qBAAqBC,IAAiC;IAC1E,MAAMN,WAAiB,wBAAwB;QAACO,QAAQ;QAAQD;IAAI;AACtE;AAEA,OAAO,eAAeE,qBAAqBF,IAAiC;IAC1E,MAAMG,WAAW,MAAMR,kBACrBF,oCACA,gCACA;QACEQ,QAAQ;QACRD;IACF;IAEF,OAAOF,uBAAuBK;AAChC;AAEA,OAAO,SAASC;IACd,OAAOR,YAAY;QAACS,YAAYN;IAAoB;AACtD;AAEA,OAAO,SAASO;IACd,MAAM,EAACC,kBAAkB,EAAC,GAAGV;IAE7B,OAAOD,YAAY;QACjBS,YAAYH;QACZM,WAAWD;IACb;AACF"}
1
+ {"version":3,"sources":["../../../src/hooks/api/password-reset-auth.ts"],"sourcesContent":["import {passwordResetConfirmResponseSchema} from '@shipfox/api-auth-dto';\nimport {checkedApiRequest, emptyResponseSchema} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport type {PasswordResetConfirmCommand, PasswordResetRequestCommand} from '#core/auth.js';\nimport {useAuthTransition} from '#state/auth.js';\nimport {toAuthenticatedSession} from './auth-mapper.js';\n\nexport async function requestPasswordReset(command: PasswordResetRequestCommand) {\n await checkedApiRequest(emptyResponseSchema, '/auth/password-reset', {\n method: 'POST',\n body: command,\n });\n}\n\nexport async function confirmPasswordReset(command: PasswordResetConfirmCommand) {\n const response = await checkedApiRequest(\n passwordResetConfirmResponseSchema,\n '/auth/password-reset/confirm',\n {\n method: 'POST',\n body: {token: command.token, new_password: command.newPassword},\n },\n );\n return toAuthenticatedSession(response);\n}\n\nexport function useRequestPasswordResetAuth() {\n return useMutation({mutationFn: requestPasswordReset});\n}\n\nexport function useConfirmPasswordResetAuth() {\n const {enterAuthenticated} = useAuthTransition();\n\n return useMutation({\n mutationFn: confirmPasswordReset,\n onSuccess: (session) => enterAuthenticated(session),\n });\n}\n"],"names":["passwordResetConfirmResponseSchema","checkedApiRequest","emptyResponseSchema","useMutation","useAuthTransition","toAuthenticatedSession","requestPasswordReset","command","method","body","confirmPasswordReset","response","token","new_password","newPassword","useRequestPasswordResetAuth","mutationFn","useConfirmPasswordResetAuth","enterAuthenticated","onSuccess","session"],"mappings":"AAAA,SAAQA,kCAAkC,QAAO,wBAAwB;AACzE,SAAQC,iBAAiB,EAAEC,mBAAmB,QAAO,sBAAsB;AAC3E,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,iBAAiB,QAAO,iBAAiB;AACjD,SAAQC,sBAAsB,QAAO,mBAAmB;AAExD,OAAO,eAAeC,qBAAqBC,OAAoC;IAC7E,MAAMN,kBAAkBC,qBAAqB,wBAAwB;QACnEM,QAAQ;QACRC,MAAMF;IACR;AACF;AAEA,OAAO,eAAeG,qBAAqBH,OAAoC;IAC7E,MAAMI,WAAW,MAAMV,kBACrBD,oCACA,gCACA;QACEQ,QAAQ;QACRC,MAAM;YAACG,OAAOL,QAAQK,KAAK;YAAEC,cAAcN,QAAQO,WAAW;QAAA;IAChE;IAEF,OAAOT,uBAAuBM;AAChC;AAEA,OAAO,SAASI;IACd,OAAOZ,YAAY;QAACa,YAAYV;IAAoB;AACtD;AAEA,OAAO,SAASW;IACd,MAAM,EAACC,kBAAkB,EAAC,GAAGd;IAE7B,OAAOD,YAAY;QACjBa,YAAYN;QACZS,WAAW,CAACC,UAAYF,mBAAmBE;IAC7C;AACF"}
@@ -1,2 +1,2 @@
1
- export { authRefreshQueryKey, getAuthRefreshDelayMs, useRefreshAuth, } from '@shipfox/client-shell/runtime';
1
+ export { authRefreshQueryKey, authRefreshQueryOptions, getAuthRefreshDelayMs, useRefreshAuth, } from '@shipfox/client-shell/runtime';
2
2
  //# sourceMappingURL=refresh-auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/refresh-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,GACf,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"refresh-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/refresh-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,GACf,MAAM,+BAA+B,CAAC"}
@@ -1,3 +1,3 @@
1
- export { authRefreshQueryKey, getAuthRefreshDelayMs, useRefreshAuth } from '@shipfox/client-shell/runtime';
1
+ export { authRefreshQueryKey, authRefreshQueryOptions, getAuthRefreshDelayMs, useRefreshAuth } from '@shipfox/client-shell/runtime';
2
2
 
3
3
  //# sourceMappingURL=refresh-auth.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/refresh-auth.ts"],"sourcesContent":["export {\n authRefreshQueryKey,\n getAuthRefreshDelayMs,\n useRefreshAuth,\n} from '@shipfox/client-shell/runtime';\n"],"names":["authRefreshQueryKey","getAuthRefreshDelayMs","useRefreshAuth"],"mappings":"AAAA,SACEA,mBAAmB,EACnBC,qBAAqB,EACrBC,cAAc,QACT,gCAAgC"}
1
+ {"version":3,"sources":["../../../src/hooks/api/refresh-auth.ts"],"sourcesContent":["export {\n authRefreshQueryKey,\n authRefreshQueryOptions,\n getAuthRefreshDelayMs,\n useRefreshAuth,\n} from '@shipfox/client-shell/runtime';\n"],"names":["authRefreshQueryKey","authRefreshQueryOptions","getAuthRefreshDelayMs","useRefreshAuth"],"mappings":"AAAA,SACEA,mBAAmB,EACnBC,uBAAuB,EACvBC,qBAAqB,EACrBC,cAAc,QACT,gCAAgC"}
@@ -1,7 +1,3 @@
1
- export declare function useSignupAuth(): import("@tanstack/react-query").UseMutationResult<import("./auth-mapper.js").SignupResult, Error, {
2
- email: string;
3
- password: string;
4
- name: string;
5
- invitation_token?: string | undefined;
6
- }, unknown>;
1
+ import type { SignupCommand } from '#core/auth.js';
2
+ export declare function useSignupAuth(): import("@tanstack/react-query").UseMutationResult<import("#core/auth.js").SignupResult, Error, SignupCommand, unknown>;
7
3
  //# sourceMappingURL=signup-auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signup-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/signup-auth.ts"],"names":[],"mappings":"AAaA,wBAAgB,aAAa;;;;;YAE5B"}
1
+ {"version":3,"file":"signup-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/signup-auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAgBjD,wBAAgB,aAAa,2HAE5B"}
@@ -2,10 +2,17 @@ import { signupResponseSchema } from '@shipfox/api-auth-dto';
2
2
  import { checkedApiRequest } from '@shipfox/client-api';
3
3
  import { useMutation } from '@tanstack/react-query';
4
4
  import { toSignupResult } from './auth-mapper.js';
5
- async function signupAuth(body) {
5
+ async function signupAuth(command) {
6
6
  const response = await checkedApiRequest(signupResponseSchema, '/auth/signup', {
7
7
  method: 'POST',
8
- body
8
+ body: {
9
+ email: command.email,
10
+ password: command.password,
11
+ name: command.name,
12
+ ...command.invitationToken ? {
13
+ invitation_token: command.invitationToken
14
+ } : {}
15
+ }
9
16
  });
10
17
  return toSignupResult(response);
11
18
  }