@salesforce/webapp-template-feature-react-authentication-experimental 1.43.1 → 1.45.0

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 (41) hide show
  1. package/dist/CHANGELOG.md +16 -0
  2. package/dist/force-app/main/default/webapplications/feature-react-authentication/package-lock.json +1306 -534
  3. package/dist/force-app/main/default/webapplications/feature-react-authentication/package.json +1 -3
  4. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/app.tsx +2 -5
  5. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/authHelpers.ts +73 -0
  6. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/{utils → components/auth}/authenticationConfig.ts +9 -0
  7. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/{authentication-route.tsx → authenticationRouteLayout.tsx} +1 -1
  8. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/{private-route.tsx → privateRouteLayout.tsx} +1 -1
  9. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/sessionTimeout/SessionTimeoutValidator.tsx +616 -0
  10. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/sessionTimeout/sessionTimeService.ts +161 -0
  11. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/auth/sessionTimeout/sessionTimeoutConfig.ts +77 -0
  12. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/alert.tsx +17 -13
  13. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/button.tsx +35 -22
  14. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/card.tsx +27 -12
  15. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/dialog.tsx +143 -0
  16. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/field.tsx +157 -46
  17. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/index.ts +1 -0
  18. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/input.tsx +3 -3
  19. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/label.tsx +2 -2
  20. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/pagination.tsx +87 -74
  21. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/select.tsx +156 -124
  22. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/separator.tsx +26 -0
  23. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/skeleton.tsx +1 -0
  24. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/spinner.tsx +5 -16
  25. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/table.tsx +68 -95
  26. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/components/ui/tabs.tsx +47 -84
  27. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/context/AuthContext.tsx +12 -0
  28. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/hooks/form.tsx +1 -1
  29. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/hooks/useCountdownTimer.ts +266 -0
  30. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/hooks/useRetryWithBackoff.ts +109 -0
  31. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/layouts/AuthAppLayout.tsx +12 -0
  32. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/ChangePassword.tsx +3 -2
  33. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/ForgotPassword.tsx +1 -1
  34. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/Login.tsx +3 -3
  35. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/Profile.tsx +3 -2
  36. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/Register.tsx +4 -5
  37. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/pages/ResetPassword.tsx +3 -2
  38. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/routes.tsx +5 -5
  39. package/dist/force-app/main/default/webapplications/feature-react-authentication/src/utils/helpers.ts +0 -74
  40. package/dist/package.json +1 -1
  41. package/package.json +3 -3
@@ -6,8 +6,9 @@ import { CenteredPageLayout } from "../components/layout/centered-page-layout";
6
6
  import { AuthForm } from "../components/forms/auth-form";
7
7
  import { StatusAlert } from "../components/alerts/status-alert";
8
8
  import { useAppForm } from "../hooks/form";
9
- import { ROUTES, AUTH_PLACEHOLDERS } from "../utils/authenticationConfig";
10
- import { newPasswordSchema, handleApiResponse, getErrorMessage } from "../utils/helpers";
9
+ import { ROUTES, AUTH_PLACEHOLDERS } from "../components/auth/authenticationConfig";
10
+ import { newPasswordSchema } from "../components/auth/authHelpers";
11
+ import { handleApiResponse, getErrorMessage } from "../utils/helpers";
11
12
 
12
13
  export default function ResetPassword() {
13
14
  const [searchParams] = useSearchParams();
@@ -1,21 +1,21 @@
1
1
  import type { RouteObject } from 'react-router';
2
- import AppLayout from './appLayout';
3
2
  import Home from './pages/Home';
4
3
  import NotFound from './pages/NotFound';
4
+ import AuthAppLayout from "./layouts/AuthAppLayout";
5
5
  import Login from "./pages/Login";
6
6
  import Register from "./pages/Register";
7
7
  import ForgotPassword from "./pages/ForgotPassword";
8
8
  import ResetPassword from "./pages/ResetPassword";
9
9
  import Profile from "./pages/Profile";
10
10
  import ChangePassword from "./pages/ChangePassword";
11
- import AuthenticationRoute from "./components/auth/authentication-route";
12
- import PrivateRoute from "./components/auth/private-route";
13
- import { ROUTES } from "./utils/authenticationConfig";
11
+ import AuthenticationRoute from "./components/auth/authenticationRouteLayout";
12
+ import PrivateRoute from "./components/auth/privateRouteLayout";
13
+ import { ROUTES } from "./components/auth/authenticationConfig";
14
14
 
15
15
  export const routes: RouteObject[] = [
16
16
  {
17
17
  path: "/",
18
- element: <AppLayout />,
18
+ element: <AuthAppLayout />,
19
19
  children: [
20
20
  {
21
21
  index: true,
@@ -1,66 +1,3 @@
1
- import { AUTH_REDIRECT_PARAM } from "./authenticationConfig";
2
- import { z } from "zod";
3
-
4
- /** Email field validation */
5
- export const emailSchema = z.string().trim().email("Please enter a valid email address");
6
-
7
- /** Password field validation (minimum 8 characters) */
8
- export const passwordSchema = z.string().min(8, "Password must be at least 8 characters");
9
-
10
- /**
11
- * Shared schema for new password + confirmation fields.
12
- * Validates password length and matching confirmation.
13
- */
14
- export const newPasswordSchema = z
15
- .object({
16
- newPassword: passwordSchema,
17
- confirmPassword: z.string().min(1, "Please confirm your password"),
18
- })
19
- .refine((data) => data.newPassword === data.confirmPassword, {
20
- message: "Passwords do not match",
21
- path: ["confirmPassword"],
22
- });
23
-
24
- /**
25
- *
26
- * Extracts the startUrl from URLSearchParams, defaulting to '/'.
27
- *
28
- * SECURITY NOTE: This function strictly validates the URL to prevent
29
- * Open Redirect vulnerabilities. It allows only relative paths.
30
- *
31
- * @param searchParams - The URLSearchParams object from useSearchParams()
32
- * @returns The start URL for post-authentication redirect
33
- */
34
- export function getStartUrl(searchParams: URLSearchParams): string {
35
- // 1. Check for the standard redirect parameter
36
- const url = searchParams.get(AUTH_REDIRECT_PARAM);
37
- // 2. Security Check: Validation Logic
38
- if (url && isValidRedirect(url)) {
39
- return url;
40
- }
41
- // 3. Fallback: Default to root
42
- return "/";
43
- }
44
-
45
- /**
46
- * [Dev Note] Security: Validates that the redirect URL is a relative path
47
- * to prevent Open Redirect vulnerabilities.
48
- *
49
- * Security Checks:
50
- * 1. Rejects protocol-relative URLs (//)
51
- * 2. Rejects backslash usage which some browsers treat as slashes (/\)
52
- * 3. Rejects control characters
53
- */
54
- function isValidRedirect(url: string): boolean {
55
- // Basic structure check
56
- if (!url.startsWith("/") || url.startsWith("//")) return false;
57
- // Security: Reject backslashes to prevent /\example.com bypasses
58
- if (url.includes("\\")) return false;
59
- // Robustness: Ensure it doesn't contain whitespace/control characters
60
- if (/[^\u0021-\u00ff]/.test(url)) return false;
61
- return true;
62
- }
63
-
64
1
  /**
65
2
  * MAINTAINABILITY: Robust error extraction.
66
3
  * Handles strings, objects, and standard Error instances.
@@ -112,17 +49,6 @@ export async function handleApiResponse<T = unknown>(
112
49
  return data as T;
113
50
  }
114
51
 
115
- /**
116
- * Shared response type for authentication endpoints (login/register).
117
- * Success responses contain `success: true` and `redirectUrl`.
118
- * Error responses contain `errors` array.
119
- */
120
- export interface AuthResponse {
121
- success?: boolean;
122
- redirectUrl?: string | null;
123
- errors?: string[];
124
- }
125
-
126
52
  /**
127
53
  * UI API Record response structure.
128
54
  */
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.43.1",
3
+ "version": "1.45.0",
4
4
  "description": "Base SFDX project template",
5
5
  "private": true,
6
6
  "files": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-feature-react-authentication-experimental",
3
- "version": "1.43.1",
3
+ "version": "1.45.0",
4
4
  "description": "Authentication feature for web applications",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -16,7 +16,7 @@
16
16
  "clean": "rm -rf dist"
17
17
  },
18
18
  "devDependencies": {
19
- "@salesforce/webapp-experimental": "^1.43.1",
19
+ "@salesforce/webapp-experimental": "^1.45.0",
20
20
  "@tanstack/react-form": "^1.27.7",
21
21
  "@types/react": "^19.2.7",
22
22
  "@types/react-dom": "^19.2.3",
@@ -40,5 +40,5 @@
40
40
  }
41
41
  }
42
42
  },
43
- "gitHead": "639c5bac6d7004d13246a86c9db4b33667da7c30"
43
+ "gitHead": "7c993c5088a22672b43d457613fbbbbdfd46a755"
44
44
  }