@shipfox/client-auth 5.0.0 → 6.0.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.
Files changed (109) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +43 -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/core/auth.d.ts +57 -0
  11. package/dist/core/auth.d.ts.map +1 -0
  12. package/dist/core/auth.js +3 -0
  13. package/dist/core/auth.js.map +1 -0
  14. package/dist/hooks/api/auth-mapper.d.ts +2 -17
  15. package/dist/hooks/api/auth-mapper.d.ts.map +1 -1
  16. package/dist/hooks/api/auth-mapper.js.map +1 -1
  17. package/dist/hooks/api/login-auth.d.ts +3 -6
  18. package/dist/hooks/api/login-auth.d.ts.map +1 -1
  19. package/dist/hooks/api/login-auth.js +2 -2
  20. package/dist/hooks/api/login-auth.js.map +1 -1
  21. package/dist/hooks/api/logout-auth.js +2 -2
  22. package/dist/hooks/api/logout-auth.js.map +1 -1
  23. package/dist/hooks/api/password-reset-auth.d.ts +5 -10
  24. package/dist/hooks/api/password-reset-auth.d.ts.map +1 -1
  25. package/dist/hooks/api/password-reset-auth.js +9 -6
  26. package/dist/hooks/api/password-reset-auth.js.map +1 -1
  27. package/dist/hooks/api/refresh-auth.d.ts +1 -1
  28. package/dist/hooks/api/refresh-auth.d.ts.map +1 -1
  29. package/dist/hooks/api/refresh-auth.js +1 -1
  30. package/dist/hooks/api/refresh-auth.js.map +1 -1
  31. package/dist/hooks/api/signup-auth.d.ts +2 -6
  32. package/dist/hooks/api/signup-auth.d.ts.map +1 -1
  33. package/dist/hooks/api/signup-auth.js +9 -2
  34. package/dist/hooks/api/signup-auth.js.map +1 -1
  35. package/dist/hooks/api/verify-email-auth.d.ts +4 -10
  36. package/dist/hooks/api/verify-email-auth.d.ts.map +1 -1
  37. package/dist/hooks/api/verify-email-auth.js +15 -5
  38. package/dist/hooks/api/verify-email-auth.js.map +1 -1
  39. package/dist/hooks/api/workspace-auth.d.ts +5 -7
  40. package/dist/hooks/api/workspace-auth.d.ts.map +1 -1
  41. package/dist/hooks/api/workspace-auth.js +6 -4
  42. package/dist/hooks/api/workspace-auth.js.map +1 -1
  43. package/dist/hooks/api/workspace-mapper.d.ts +1 -5
  44. package/dist/hooks/api/workspace-mapper.d.ts.map +1 -1
  45. package/dist/hooks/api/workspace-mapper.js.map +1 -1
  46. package/dist/pages/login-page.d.ts.map +1 -1
  47. package/dist/pages/login-page.js +4 -5
  48. package/dist/pages/login-page.js.map +1 -1
  49. package/dist/pages/logout-page.d.ts.map +1 -1
  50. package/dist/pages/logout-page.js +8 -18
  51. package/dist/pages/logout-page.js.map +1 -1
  52. package/dist/pages/password-reset-page.d.ts.map +1 -1
  53. package/dist/pages/password-reset-page.js +8 -7
  54. package/dist/pages/password-reset-page.js.map +1 -1
  55. package/dist/pages/signup-page.d.ts.map +1 -1
  56. package/dist/pages/signup-page.js +16 -10
  57. package/dist/pages/signup-page.js.map +1 -1
  58. package/dist/pages/workspace-onboarding-page.js +2 -2
  59. package/dist/pages/workspace-onboarding-page.js.map +1 -1
  60. package/dist/routes/inputs.d.ts +9 -0
  61. package/dist/routes/inputs.d.ts.map +1 -0
  62. package/dist/routes/inputs.js +17 -0
  63. package/dist/routes/inputs.js.map +1 -0
  64. package/dist/routes/login.d.ts +2 -0
  65. package/dist/routes/login.d.ts.map +1 -1
  66. package/dist/routes/login.js +2 -0
  67. package/dist/routes/login.js.map +1 -1
  68. package/dist/routes/logout.d.ts +2 -0
  69. package/dist/routes/logout.d.ts.map +1 -1
  70. package/dist/routes/logout.js +2 -0
  71. package/dist/routes/logout.js.map +1 -1
  72. package/dist/routes/reset.d.ts +2 -0
  73. package/dist/routes/reset.d.ts.map +1 -1
  74. package/dist/routes/reset.js +2 -0
  75. package/dist/routes/reset.js.map +1 -1
  76. package/dist/routes/signup.d.ts +2 -0
  77. package/dist/routes/signup.d.ts.map +1 -1
  78. package/dist/routes/signup.js +2 -0
  79. package/dist/routes/signup.js.map +1 -1
  80. package/dist/tsconfig.test.tsbuildinfo +1 -1
  81. package/package.json +11 -12
  82. package/src/components/auth-guard.tsx +4 -2
  83. package/src/components/redirect-target.test.ts +32 -1
  84. package/src/components/redirect-target.ts +41 -4
  85. package/src/core/auth.ts +55 -0
  86. package/src/hooks/api/auth-mapper.ts +2 -12
  87. package/src/hooks/api/login-auth.ts +4 -3
  88. package/src/hooks/api/logout-auth.ts +2 -2
  89. package/src/hooks/api/password-reset-auth.test.ts +2 -2
  90. package/src/hooks/api/password-reset-auth.ts +10 -10
  91. package/src/hooks/api/refresh-auth.ts +1 -0
  92. package/src/hooks/api/signup-auth.ts +9 -3
  93. package/src/hooks/api/verify-email-auth.ts +19 -9
  94. package/src/hooks/api/workspace-auth.ts +10 -5
  95. package/src/hooks/api/workspace-mapper.ts +1 -6
  96. package/src/pages/login-page.tsx +4 -3
  97. package/src/pages/logout-page.test.tsx +75 -0
  98. package/src/pages/logout-page.tsx +9 -13
  99. package/src/pages/password-reset-page.tsx +5 -5
  100. package/src/pages/signup-page.tsx +14 -8
  101. package/src/pages/workspace-onboarding-page.tsx +2 -2
  102. package/src/routes/inputs.test.ts +17 -0
  103. package/src/routes/inputs.ts +21 -0
  104. package/src/routes/login.tsx +2 -0
  105. package/src/routes/logout.tsx +2 -1
  106. package/src/routes/reset.tsx +2 -0
  107. package/src/routes/signup.tsx +2 -0
  108. package/tsconfig.build.tsbuildinfo +1 -1
  109. 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 (135.57ms)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @shipfox/client-auth
2
2
 
3
+ ## 6.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 475ce59: Republishes all public packages after restoring release authorization.
8
+ - 3f8f1cb: Enforces typed route-input and browser-storage boundaries across client features.
9
+ - Updated dependencies [475ce59]
10
+ - Updated dependencies [3f8f1cb]
11
+ - @shipfox/api-auth-dto@9.0.1
12
+ - @shipfox/api-workspaces-dto@9.0.1
13
+ - @shipfox/client-api@6.0.1
14
+ - @shipfox/client-invitations@6.0.1
15
+ - @shipfox/client-shell@6.0.1
16
+ - @shipfox/client-ui@6.0.1
17
+ - @shipfox/react-ui@0.3.6
18
+
19
+ ## 6.0.0
20
+
21
+ ### Minor Changes
22
+
23
+ - cd90c19: Enforces package-owned query policies and explicit cache-operation ownership across client resources.
24
+
25
+ ### Patch Changes
26
+
27
+ - d784a07: Enforces checked client API responses and removes stale transport compatibility helpers.
28
+ - 891e469: Adds a sanitized logout redirect that clears local and server auth state before returning to a safe same-origin destination.
29
+ - c56c124: Converges auth sessions and invitation responses on checked domain boundaries.
30
+ - Updated dependencies [401b583]
31
+ - Updated dependencies [82eda45]
32
+ - Updated dependencies [9c9d266]
33
+ - Updated dependencies [cd90c19]
34
+ - Updated dependencies [24be269]
35
+ - Updated dependencies [c56c124]
36
+ - Updated dependencies [4a6d124]
37
+ - Updated dependencies [c02ac42]
38
+ - @shipfox/client-shell@6.0.0
39
+ - @shipfox/api-workspaces-dto@9.0.0
40
+ - @shipfox/client-api@6.0.0
41
+ - @shipfox/client-invitations@6.0.0
42
+ - @shipfox/api-auth-dto@7.1.0
43
+ - @shipfox/client-ui@6.0.0
44
+ - @shipfox/react-ui@0.3.5
45
+
3
46
  ## 5.0.0
4
47
 
5
48
  ### 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"}
@@ -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
  }
@@ -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: enterAuthenticated,\n });\n}\n"],"names":["loginResponseSchema","checkedApiRequest","useMutation","useAuthTransition","toAuthenticatedSession","loginAuth","command","response","method","body","useLoginAuth","enterAuthenticated","mutationFn","onSuccess"],"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,WAAWF;IACb;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
  });
@@ -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,WAAWF;IACb;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
  }
@@ -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: enterAuthenticated,\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"],"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,WAAWD;IACb;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
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/signup-auth.ts"],"sourcesContent":["import {type SignupBodyDto, signupResponseSchema} from '@shipfox/api-auth-dto';\nimport {checkedApiRequest} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport {toSignupResult} from './auth-mapper.js';\n\nasync function signupAuth(body: SignupBodyDto) {\n const response = await checkedApiRequest(signupResponseSchema, '/auth/signup', {\n method: 'POST',\n body,\n });\n return toSignupResult(response);\n}\n\nexport function useSignupAuth() {\n return useMutation({mutationFn: signupAuth});\n}\n"],"names":["signupResponseSchema","checkedApiRequest","useMutation","toSignupResult","signupAuth","body","response","method","useSignupAuth","mutationFn"],"mappings":"AAAA,SAA4BA,oBAAoB,QAAO,wBAAwB;AAC/E,SAAQC,iBAAiB,QAAO,sBAAsB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,cAAc,QAAO,mBAAmB;AAEhD,eAAeC,WAAWC,IAAmB;IAC3C,MAAMC,WAAW,MAAML,kBAAkBD,sBAAsB,gBAAgB;QAC7EO,QAAQ;QACRF;IACF;IACA,OAAOF,eAAeG;AACxB;AAEA,OAAO,SAASE;IACd,OAAON,YAAY;QAACO,YAAYL;IAAU;AAC5C"}
1
+ {"version":3,"sources":["../../../src/hooks/api/signup-auth.ts"],"sourcesContent":["import {signupResponseSchema} from '@shipfox/api-auth-dto';\nimport {checkedApiRequest} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport type {SignupCommand} from '#core/auth.js';\nimport {toSignupResult} from './auth-mapper.js';\n\nasync function signupAuth(command: SignupCommand) {\n const response = await checkedApiRequest(signupResponseSchema, '/auth/signup', {\n method: 'POST',\n body: {\n email: command.email,\n password: command.password,\n name: command.name,\n ...(command.invitationToken ? {invitation_token: command.invitationToken} : {}),\n },\n });\n return toSignupResult(response);\n}\n\nexport function useSignupAuth() {\n return useMutation({mutationFn: signupAuth});\n}\n"],"names":["signupResponseSchema","checkedApiRequest","useMutation","toSignupResult","signupAuth","command","response","method","body","email","password","name","invitationToken","invitation_token","useSignupAuth","mutationFn"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,wBAAwB;AAC3D,SAAQC,iBAAiB,QAAO,sBAAsB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,cAAc,QAAO,mBAAmB;AAEhD,eAAeC,WAAWC,OAAsB;IAC9C,MAAMC,WAAW,MAAML,kBAAkBD,sBAAsB,gBAAgB;QAC7EO,QAAQ;QACRC,MAAM;YACJC,OAAOJ,QAAQI,KAAK;YACpBC,UAAUL,QAAQK,QAAQ;YAC1BC,MAAMN,QAAQM,IAAI;YAClB,GAAIN,QAAQO,eAAe,GAAG;gBAACC,kBAAkBR,QAAQO,eAAe;YAAA,IAAI,CAAC,CAAC;QAChF;IACF;IACA,OAAOT,eAAeG;AACxB;AAEA,OAAO,SAASQ;IACd,OAAOZ,YAAY;QAACa,YAAYX;IAAU;AAC5C"}
@@ -1,12 +1,6 @@
1
+ import type { ResendEmailVerificationCommand, VerifyEmailCommand } from '#core/auth.js';
1
2
  export declare function useResendEmailVerificationAuth(): import("@tanstack/react-query").UseMutationResult<{
2
- next_resend_available_at: string;
3
- }, Error, {
4
- email: string;
5
- challenge_id: string;
6
- }, unknown>;
7
- export declare function useVerifyEmailAuth(): import("@tanstack/react-query").UseMutationResult<import("@shipfox/client-shell/runtime").AuthenticatedSession, Error, {
8
- email: string;
9
- challenge_id: string;
10
- code: string;
11
- }, unknown>;
3
+ nextResendAvailableAt: string;
4
+ }, Error, ResendEmailVerificationCommand, unknown>;
5
+ export declare function useVerifyEmailAuth(): import("@tanstack/react-query").UseMutationResult<import("@shipfox/client-shell/runtime").AuthenticatedSession, Error, VerifyEmailCommand, unknown>;
12
6
  //# sourceMappingURL=verify-email-auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify-email-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/verify-email-auth.ts"],"names":[],"mappings":"AA8BA,wBAAgB,8BAA8B;;;;;YAE7C;AAED,wBAAgB,kBAAkB;;;;YAOjC"}
1
+ {"version":3,"file":"verify-email-auth.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/verify-email-auth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,8BAA8B,EAC9B,kBAAkB,EACnB,MAAM,eAAe,CAAC;AA8BvB,wBAAgB,8BAA8B;;mDAE7C;AAED,wBAAgB,kBAAkB,wJAOjC"}
@@ -3,18 +3,28 @@ 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
- async function verifyEmailAuth(body) {
6
+ async function verifyEmailAuth(command) {
7
7
  const response = await checkedApiRequest(verifyEmailConfirmResponseSchema, '/auth/verify-email/confirm', {
8
8
  method: 'POST',
9
- body
9
+ body: {
10
+ email: command.email,
11
+ challenge_id: command.challengeId,
12
+ code: command.code
13
+ }
10
14
  });
11
15
  return toAuthenticatedSession(response);
12
16
  }
13
- async function resendEmailVerificationAuth(body) {
14
- return await checkedApiRequest(verifyEmailResendResponseSchema, '/auth/verify-email/resend', {
17
+ async function resendEmailVerificationAuth(command) {
18
+ const response = await checkedApiRequest(verifyEmailResendResponseSchema, '/auth/verify-email/resend', {
15
19
  method: 'POST',
16
- body
20
+ body: {
21
+ email: command.email,
22
+ challenge_id: command.challengeId
23
+ }
17
24
  });
25
+ return {
26
+ nextResendAvailableAt: response.next_resend_available_at
27
+ };
18
28
  }
19
29
  export function useResendEmailVerificationAuth() {
20
30
  return useMutation({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/api/verify-email-auth.ts"],"sourcesContent":["import {\n type VerifyEmailConfirmBodyDto,\n type VerifyEmailResendBodyDto,\n verifyEmailConfirmResponseSchema,\n verifyEmailResendResponseSchema,\n} 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\nasync function verifyEmailAuth(body: VerifyEmailConfirmBodyDto) {\n const response = await checkedApiRequest(\n verifyEmailConfirmResponseSchema,\n '/auth/verify-email/confirm',\n {\n method: 'POST',\n body,\n },\n );\n return toAuthenticatedSession(response);\n}\n\nasync function resendEmailVerificationAuth(body: VerifyEmailResendBodyDto) {\n return await checkedApiRequest(verifyEmailResendResponseSchema, '/auth/verify-email/resend', {\n method: 'POST',\n body,\n });\n}\n\nexport function useResendEmailVerificationAuth() {\n return useMutation({mutationFn: resendEmailVerificationAuth});\n}\n\nexport function useVerifyEmailAuth() {\n const {enterAuthenticated} = useAuthTransition();\n\n return useMutation({\n mutationFn: verifyEmailAuth,\n onSuccess: enterAuthenticated,\n });\n}\n"],"names":["verifyEmailConfirmResponseSchema","verifyEmailResendResponseSchema","checkedApiRequest","useMutation","useAuthTransition","toAuthenticatedSession","verifyEmailAuth","body","response","method","resendEmailVerificationAuth","useResendEmailVerificationAuth","mutationFn","useVerifyEmailAuth","enterAuthenticated","onSuccess"],"mappings":"AAAA,SAGEA,gCAAgC,EAChCC,+BAA+B,QAC1B,wBAAwB;AAC/B,SAAQC,iBAAiB,QAAO,sBAAsB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,iBAAiB,QAAO,iBAAiB;AACjD,SAAQC,sBAAsB,QAAO,mBAAmB;AAExD,eAAeC,gBAAgBC,IAA+B;IAC5D,MAAMC,WAAW,MAAMN,kBACrBF,kCACA,8BACA;QACES,QAAQ;QACRF;IACF;IAEF,OAAOF,uBAAuBG;AAChC;AAEA,eAAeE,4BAA4BH,IAA8B;IACvE,OAAO,MAAML,kBAAkBD,iCAAiC,6BAA6B;QAC3FQ,QAAQ;QACRF;IACF;AACF;AAEA,OAAO,SAASI;IACd,OAAOR,YAAY;QAACS,YAAYF;IAA2B;AAC7D;AAEA,OAAO,SAASG;IACd,MAAM,EAACC,kBAAkB,EAAC,GAAGV;IAE7B,OAAOD,YAAY;QACjBS,YAAYN;QACZS,WAAWD;IACb;AACF"}
1
+ {"version":3,"sources":["../../../src/hooks/api/verify-email-auth.ts"],"sourcesContent":["import {\n verifyEmailConfirmResponseSchema,\n verifyEmailResendResponseSchema,\n} from '@shipfox/api-auth-dto';\nimport {checkedApiRequest} from '@shipfox/client-api';\nimport {useMutation} from '@tanstack/react-query';\nimport type {\n EmailVerificationResendResult,\n ResendEmailVerificationCommand,\n VerifyEmailCommand,\n} from '#core/auth.js';\nimport {useAuthTransition} from '#state/auth.js';\nimport {toAuthenticatedSession} from './auth-mapper.js';\n\nasync function verifyEmailAuth(command: VerifyEmailCommand) {\n const response = await checkedApiRequest(\n verifyEmailConfirmResponseSchema,\n '/auth/verify-email/confirm',\n {\n method: 'POST',\n body: {email: command.email, challenge_id: command.challengeId, code: command.code},\n },\n );\n return toAuthenticatedSession(response);\n}\n\nasync function resendEmailVerificationAuth(command: ResendEmailVerificationCommand) {\n const response = await checkedApiRequest(\n verifyEmailResendResponseSchema,\n '/auth/verify-email/resend',\n {\n method: 'POST',\n body: {email: command.email, challenge_id: command.challengeId},\n },\n );\n return {\n nextResendAvailableAt: response.next_resend_available_at,\n } satisfies EmailVerificationResendResult;\n}\n\nexport function useResendEmailVerificationAuth() {\n return useMutation({mutationFn: resendEmailVerificationAuth});\n}\n\nexport function useVerifyEmailAuth() {\n const {enterAuthenticated} = useAuthTransition();\n\n return useMutation({\n mutationFn: verifyEmailAuth,\n onSuccess: enterAuthenticated,\n });\n}\n"],"names":["verifyEmailConfirmResponseSchema","verifyEmailResendResponseSchema","checkedApiRequest","useMutation","useAuthTransition","toAuthenticatedSession","verifyEmailAuth","command","response","method","body","email","challenge_id","challengeId","code","resendEmailVerificationAuth","nextResendAvailableAt","next_resend_available_at","useResendEmailVerificationAuth","mutationFn","useVerifyEmailAuth","enterAuthenticated","onSuccess"],"mappings":"AAAA,SACEA,gCAAgC,EAChCC,+BAA+B,QAC1B,wBAAwB;AAC/B,SAAQC,iBAAiB,QAAO,sBAAsB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAMlD,SAAQC,iBAAiB,QAAO,iBAAiB;AACjD,SAAQC,sBAAsB,QAAO,mBAAmB;AAExD,eAAeC,gBAAgBC,OAA2B;IACxD,MAAMC,WAAW,MAAMN,kBACrBF,kCACA,8BACA;QACES,QAAQ;QACRC,MAAM;YAACC,OAAOJ,QAAQI,KAAK;YAAEC,cAAcL,QAAQM,WAAW;YAAEC,MAAMP,QAAQO,IAAI;QAAA;IACpF;IAEF,OAAOT,uBAAuBG;AAChC;AAEA,eAAeO,4BAA4BR,OAAuC;IAChF,MAAMC,WAAW,MAAMN,kBACrBD,iCACA,6BACA;QACEQ,QAAQ;QACRC,MAAM;YAACC,OAAOJ,QAAQI,KAAK;YAAEC,cAAcL,QAAQM,WAAW;QAAA;IAChE;IAEF,OAAO;QACLG,uBAAuBR,SAASS,wBAAwB;IAC1D;AACF;AAEA,OAAO,SAASC;IACd,OAAOf,YAAY;QAACgB,YAAYJ;IAA2B;AAC7D;AAEA,OAAO,SAASK;IACd,MAAM,EAACC,kBAAkB,EAAC,GAAGjB;IAE7B,OAAOD,YAAY;QACjBgB,YAAYb;QACZgB,WAAWD;IACb;AACF"}