A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.
TypeScript amazon-primeelectronepic-games-launcherepic-games-storeepic-storegaminggoggog-galaxyheroic-games-launcherlinuxplay-gamesprotonsteamwine
[Feat] Fortnite on Linux anticheat notice (#6198)
Flávio Fearnb899d0889e9a
diff --git a/public/locales/en/translation.json b/public/locales/en/translation.jsonindex 933be04bf..d9e6bd5b9 100644--- a/public/locales/en/translation.json+++ b/public/locales/en/translation.json@@ -46,6 +46,14 @@},"anticheat": {"anticheats": "Anticheats",+ "fortnite_linux": {+ "body": "Epic has enabled Easy Anti-Cheat for Linux in Fortnite. Fortnite runs in Heroic through Proton on systems that meet Epic's requirements: Secure Boot (using your distro's keys), TPM 2.0, and IOMMU enabled.",+ "caveat": "Steam Deck and SteamOS are not supported for Fortnite yet.",+ "continue_installation": "Continue installation",+ "guide": "Read Epic's Linux setup guide",+ "title": "Fortnite on Linux (beta)",+ "tracker_note": "AreWeAntiCheatYet may still list Fortnite as unsupported."+ },"multiplayer_may_not_work": "Multiplayer features may not work due to denied or broken anticheat support.","reference": "Reference","removed": "Anticheat removed",diff --git a/src/frontend/__tests__/fortnite-linux-anticheat.test.tsx b/src/frontend/__tests__/fortnite-linux-anticheat.test.tsxnew file mode 100644index 000000000..159e23df7--- /dev/null+++ b/src/frontend/__tests__/fortnite-linux-anticheat.test.tsx@@ -0,0 +1,133 @@+/**+ * @jest-environment jsdom+ */+import { render, screen } from '@testing-library/react'+import { createInstance } from 'i18next'+import { I18nextProvider } from 'react-i18next'++import Anticheat from 'frontend/components/UI/Anticheat'+import { getFortniteLinuxConfirmOptions } from 'frontend/components/UI/Anticheat/FortniteLinux'+import { anticheatConfirmationFor } from 'frontend/helpers/anticheat'+import { AntiCheatInfo } from 'common/types'+import translation from '../../../public/locales/en/translation.json'++jest.mock('frontend/components/UI/Anticheat/index.scss', () => ({}))+jest.mock('frontend/components/UI/Alert/index.css', () => ({}))+jest.mock('frontend/components/UI/Icon/index.css', () => ({}))+jest.mock('frontend/components/UI/DetailList/index.css', () => ({}))+jest.mock('frontend/components/UI/Link/index.css', () => ({}))+jest.mock('frontend/helpers', () => ({ createNewWindow: jest.fn() }))++const denied: AntiCheatInfo = {+ status: 'Denied',+ anticheats: ['Easy Anti-Cheat'],+ notes: [],+ native: false,+ storeIds: { epic: { namespace: 'fn', slug: 'fortnite' } },+ reference: 'https://areweanticheatyet.com/?search=fortnite',+ updates: []+}++const i18n = createInstance()++beforeAll(async () => {+ await i18n.init({+ lng: 'en',+ ns: ['translation'],+ defaultNS: 'translation',+ resources: { en: { translation } },+ interpolation: { escapeValue: false },+ react: { useSuspense: false }+ })+})++const renderAnticheat = (+ anticheatInfo: AntiCheatInfo | null,+ appName = 'Some Game',+ platform: NodeJS.Platform = 'linux'+) =>+ render(+ <I18nextProvider i18n={i18n}>+ <Anticheat+ anticheatInfo={anticheatInfo}+ appName={appName}+ runner="legendary"+ platform={platform}+ />+ </I18nextProvider>+ )++describe('Fortnite on Linux notice', () => {+ it.each([+ ['Denied', denied],+ ['no anticheat data', null]+ ])('shows the notice with %s and no AWACY detail', (_label, info) => {+ renderAnticheat(info, 'Fortnite')++ expect(screen.getByText('Fortnite on Linux (beta)')).toBeTruthy()+ expect(screen.queryByText('Denied')).toBeNull()+ expect(screen.queryByText('Source')).toBeNull()+ expect(screen.queryByText('Reference')).toBeNull()+ expect(screen.queryByText(/Multiplayer features may not work/)).toBeNull()+ })++ it('keeps the generic notice for other games and Fortnite on Windows', () => {+ const otherGame = renderAnticheat(denied)+ expect(+ screen.getByText('This game includes anticheat software')+ ).toBeTruthy()+ otherGame.unmount()++ renderAnticheat(denied, 'Fortnite', 'win32')+ expect(+ screen.getByText('This game includes anticheat software')+ ).toBeTruthy()+ })+})++describe('Fortnite on Linux confirmation', () => {+ it('shows the canonical copy and continues the install', () => {+ const handleInstall = jest.fn()+ const options = getFortniteLinuxConfirmOptions(+ i18n.getFixedT(null, 'translation'),+ handleInstall,+ '/games/fortnite'+ )++ render(<I18nextProvider i18n={i18n}>{options.message}</I18nextProvider>)++ expect(options.title).toBe('Fortnite on Linux (beta)')+ expect(+ screen.getByText(/Fortnite runs in Heroic through Proton/)+ ).toBeTruthy()+ expect(+ screen.getByText(+ 'Steam Deck and SteamOS are not supported for Fortnite yet.'+ )+ ).toBeTruthy()+ expect(screen.getByText(/AreWeAntiCheatYet may still list/)).toBeTruthy()+ expect(options.buttons.map((button) => button.text)).toEqual([+ 'Continue installation',+ 'Cancel'+ ])++ options.buttons[0].onClick()+ expect(handleInstall).toHaveBeenCalledWith('/games/fortnite', true)+ })+})++describe('anticheat confirmation gating', () => {+ it('uses the Fortnite flow only for Fortnite on Linux', () => {+ const fortnite = { appName: 'Fortnite', runner: 'legendary' as const }++ expect(anticheatConfirmationFor(denied, 'linux', fortnite)).toBe('fortnite')+ expect(anticheatConfirmationFor(null, 'linux', fortnite)).toBe('fortnite')+ expect(anticheatConfirmationFor(denied, 'win32', fortnite)).toBe('generic')+ expect(+ anticheatConfirmationFor(denied, 'linux', {+ appName: 'Apex Legends',+ runner: 'legendary'+ })+ ).toBe('generic')+ })+})diff --git a/src/frontend/components/UI/Anticheat/FortniteLinux.tsx b/src/frontend/components/UI/Anticheat/FortniteLinux.tsxnew file mode 100644index 000000000..adc4ddd7a--- /dev/null+++ b/src/frontend/components/UI/Anticheat/FortniteLinux.tsx@@ -0,0 +1,87 @@+import { MouseEvent } from 'react'+import type { TFunction } from 'i18next'+import { useTranslation } from 'react-i18next'+import Link from 'frontend/components/UI/Link'+import { createNewWindow } from 'frontend/helpers'+import Alert from '../Alert'++const TITLE = 'Fortnite on Linux (beta)'+const GUIDE = 'https://www.easy.ac/support/articles#linux-setup'++function FortniteLinuxCopy() {+ const { t } = useTranslation()++ const onGuideClick = (event: MouseEvent) => {+ event.preventDefault()+ createNewWindow(GUIDE)+ }++ return (+ <>+ <span className="fortniteLinuxCopy__body">+ {t(+ 'anticheat.fortnite_linux.body',+ "Epic has enabled Easy Anti-Cheat for Linux in Fortnite. Fortnite runs in Heroic through Proton on systems that meet Epic's requirements: Secure Boot (using your distro's keys), TPM 2.0, and IOMMU enabled."+ )}+ </span>+ <span className="fortniteLinuxCopy__caveat">+ {t(+ 'anticheat.fortnite_linux.caveat',+ 'Steam Deck and SteamOS are not supported for Fortnite yet.'+ )}+ </span>+ <span className="fortniteLinuxCopy__trackerNote">+ {t(+ 'anticheat.fortnite_linux.tracker_note',+ 'AreWeAntiCheatYet may still list Fortnite as unsupported.'+ )}+ </span>+ <Link+ external+ href={GUIDE}+ className="fortniteLinuxCopy__guide"+ onClick={onGuideClick}+ >+ {t('anticheat.fortnite_linux.guide', "Read Epic's Linux setup guide")}+ </Link>+ </>+ )+}++export default function FortniteLinuxNotice() {+ const { t } = useTranslation()++ return (+ <Alert+ className="anticheatInfo"+ variant="info"+ title={t('anticheat.fortnite_linux.title', TITLE)}+ >+ <FortniteLinuxCopy />+ </Alert>+ )+}++export const getFortniteLinuxConfirmOptions = (+ t: TFunction,+ handleInstall: (path?: string, ignoreAnticheat?: boolean) => unknown,+ path?: string+) => ({+ title: t('anticheat.fortnite_linux.title', TITLE),+ message: <FortniteLinuxCopy />,+ buttons: [+ {+ text: t(+ 'anticheat.fortnite_linux.continue_installation',+ 'Continue installation'+ ),+ onClick: () => {+ void handleInstall(path, true)+ }+ },+ {+ text: t('button.cancel', 'Cancel'),+ onClick: () => null+ }+ ]+})diff --git a/src/frontend/components/UI/Anticheat/index.scss b/src/frontend/components/UI/Anticheat/index.scssindex aedb42dd7..c32194af9 100644--- a/src/frontend/components/UI/Anticheat/index.scss+++ b/src/frontend/components/UI/Anticheat/index.scss@@ -1,4 +1,5 @@.anticheatInfo {+ box-sizing: border-box;max-width: 560px;margin-block: var(--space-lg);}@@ -11,6 +12,27 @@margin-top: var(--space-2xs);}+.fortniteLinuxCopy__body,+.fortniteLinuxCopy__caveat,+.fortniteLinuxCopy__trackerNote {+ display: block;+ max-width: 72ch;+}++.fortniteLinuxCopy__caveat,+.fortniteLinuxCopy__trackerNote {+ margin-top: var(--space-xs);+}++.fortniteLinuxCopy__trackerNote {+ font-size: 0.8rem;+ color: var(--text-neutral-muted);+}++.fortniteLinuxCopy__guide {+ margin-top: var(--space-xs);+}+.anticheatInfo--compact {padding-block: var(--space-sm);}diff --git a/src/frontend/components/UI/Anticheat/index.stories.tsx b/src/frontend/components/UI/Anticheat/index.stories.tsxindex 2d2a13de1..d9955997e 100644--- a/src/frontend/components/UI/Anticheat/index.stories.tsx+++ b/src/frontend/components/UI/Anticheat/index.stories.tsx@@ -82,3 +82,12 @@ export const UsesTheAlertComponent: Story = {await expect(canvasElement.querySelector('.Alert')).not.toBeNull()}}++export const FortniteOnLinux: Story = {+ args: {+ anticheatInfo: { ...base, status: 'Denied' },+ appName: 'Fortnite',+ runner: 'legendary',+ platform: 'linux'+ }+}diff --git a/src/frontend/components/UI/Anticheat/index.tsx b/src/frontend/components/UI/Anticheat/index.tsxindex 5c803ca08..c42cab14a 100644--- a/src/frontend/components/UI/Anticheat/index.tsx+++ b/src/frontend/components/UI/Anticheat/index.tsx@@ -1,15 +1,21 @@import { MouseEvent, useContext, useId, useState } from 'react'-import { AntiCheatInfo } from 'common/types'+import { AntiCheatInfo, Runner } from 'common/types'import { createNewWindow } from 'frontend/helpers'+import { isFortniteOnLinux } from 'frontend/helpers/anticheat'import { useTranslation } from 'react-i18next'import ContextProvider from 'frontend/state/ContextProvider'import './index.scss'import Alert from '../Alert'import Button from '../Button'import DetailList from '../DetailList'+import FortniteLinuxNotice from './FortniteLinux'type Props = {anticheatInfo: AntiCheatInfo | null+ appName?: string+ runner?: Runner+ // Lets stories and tests pick the platform without the app context.+ platform?: NodeJS.Platform | 'unknown'compact?: boolean}@@ -23,12 +29,25 @@ const VARIANTS = {Denied: 'error'} as const-export default function Anticheat({ anticheatInfo, compact = false }: Props) {+export default function Anticheat({+ anticheatInfo,+ appName,+ runner,+ platform: platformOverride,+ compact = false+}: Props) {const { t } = useTranslation()- const { platform } = useContext(ContextProvider)+ const { platform: contextPlatform } = useContext(ContextProvider)+ const platform = platformOverride ?? contextPlatformconst [expanded, setExpanded] = useState(!compact)const detailsId = useId()+ // Fortnite on Linux has its own notice, shown even when AreWeAntiCheatYet+ // has no data for it.+ if (isFortniteOnLinux(platform, { appName, runner })) {+ return <FortniteLinuxNotice />+ }+if (!anticheatInfo) {return null}diff --git a/src/frontend/helpers/anticheat.ts b/src/frontend/helpers/anticheat.tsnew file mode 100644index 000000000..677bcf31d--- /dev/null+++ b/src/frontend/helpers/anticheat.ts@@ -0,0 +1,35 @@+import type { AntiCheatInfo, Runner } from 'common/types'++const FORTNITE_APP_NAME = 'fortnite'+const UNSAFE_STATUSES = ['Denied', 'Broken', 'Unknown']++type Target = {+ appName?: string+ runner?: Runner+}++export function isFortniteOnLinux(+ platform: NodeJS.Platform | 'unknown' | undefined,+ { appName, runner }: Target+) {+ return (+ platform === 'linux' &&+ runner === 'legendary' &&+ appName?.toLowerCase() === FORTNITE_APP_NAME+ )+}++export function anticheatConfirmationFor(+ anticheatInfo: AntiCheatInfo | null,+ platform: NodeJS.Platform | 'unknown' | undefined,+ target: Target+): 'fortnite' | 'generic' | null {+ if (isFortniteOnLinux(platform, target)) {+ return 'fortnite'+ }++ const isUnsafe =+ !!anticheatInfo && UNSAFE_STATUSES.includes(anticheatInfo.status)++ return isUnsafe ? 'generic' : null+}diff --git a/src/frontend/screens/Game/GamePage/index.tsx b/src/frontend/screens/Game/GamePage/index.tsxindex 177a16ed7..57a9e9697 100644--- a/src/frontend/screens/Game/GamePage/index.tsx+++ b/src/frontend/screens/Game/GamePage/index.tsx@@ -839,7 +839,11 @@ export default React.memo(function GamePage(): JSX.Element | null {</TabPanel></Panel>- <Anticheat anticheatInfo={anticheatInfo} />+ <Anticheat+ anticheatInfo={anticheatInfo}+ appName={gameInfo.app_name}+ runner={gameInfo.runner}+ /></div></div></div>diff --git a/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsx b/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsxindex 3ec23f44f..7c7fcc125 100644--- a/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsx+++ b/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsx@@ -38,6 +38,7 @@ import {} from 'frontend/components/UI'import type { TabItem } from 'frontend/components/UI/Tabs'import Anticheat from 'frontend/components/UI/Anticheat'+import { getFortniteLinuxConfirmOptions } from 'frontend/components/UI/Anticheat/FortniteLinux'import {ModalHeader,ModalFooter,@@ -76,6 +77,7 @@ import GameLanguageSelector from './GameLanguageSelector'import SteamLibrarySelector from './SteamLibrarySelector'import { SteamInstallLibrary } from 'common/types/steam'import { hasAnticheatInfo } from 'frontend/hooks/hasAnticheatInfo'+import { anticheatConfirmationFor } from 'frontend/helpers/anticheat'import BranchSelector from './BranchSelector'import ZoomCollections, { type ZoomCollectionsStatus } from './ZoomCollections'import AnticheatDisabledMessage from './AnticheatDisabledMessage'@@ -321,14 +323,21 @@ export default function DownloadDialog({return}- if (- anticheatInfo &&- ['Denied', 'Broken', 'Unknown'].includes(anticheatInfo.status)- ) {- if (!ignoreAnticheat) {- confirmInstallBrokenAnticheat(path)- return- }+ const confirmation = ignoreAnticheat+ ? null+ : anticheatConfirmationFor(anticheatInfo, platform, {+ appName: gameInfo.app_name,+ runner: gameInfo.runner+ })++ if (confirmation === 'fortnite') {+ showDialogModal(getFortniteLinuxConfirmOptions(tr, handleInstall, path))+ return+ }++ if (confirmation === 'generic') {+ void confirmInstallBrokenAnticheat(path)+ return}backdropClick()@@ -1120,7 +1129,12 @@ export default function DownloadDialog({/>))}</ModalHeader>- <Anticheat anticheatInfo={anticheatInfo} compact />+ <Anticheat+ anticheatInfo={anticheatInfo}+ compact+ appName={gameInfo.app_name}+ runner={gameInfo.runner}+ /><ModalContent className="InstallModal__content">{installTabs.length > 1 && (<Tabsdiff --git a/src/frontend/screens/Library/components/InstallModal/index.scss b/src/frontend/screens/Library/components/InstallModal/index.scssindex da8a86a43..b4a231bf9 100644--- a/src/frontend/screens/Library/components/InstallModal/index.scss+++ b/src/frontend/screens/Library/components/InstallModal/index.scss@@ -17,12 +17,15 @@.InstallModal__dialog > .anticheatInfo {display: flex;+ box-sizing: border-box;+ align-self: stretch;+ width: auto;+ min-width: 0;padding: var(--space-xs) var(--space-md);gap: 0.4rem;margin: var(--space-md) var(--modal-padding-inline) 0;border-radius: var(--radius-sm);background-color: var(--current-background);- min-width: min-content;max-width: 560px;}