diff --git a/.changeset/silent-rats-retire.md b/.changeset/silent-rats-retire.md new file mode 100644 index 0000000..fd43094 --- /dev/null +++ b/.changeset/silent-rats-retire.md @@ -0,0 +1,5 @@ +--- +"ynab-sync-westpac-au": patch +--- + +Fixes issue with Westpac login treating headless chrome as an incompatible browser diff --git a/packages/westpac-au/src/export/login.ts b/packages/westpac-au/src/export/login.ts index 45eb834..eb36b20 100644 --- a/packages/westpac-au/src/export/login.ts +++ b/packages/westpac-au/src/export/login.ts @@ -51,6 +51,13 @@ export async function login( loginTimeoutInMs: 2000, } ): Promise { + // Westpac attempts to detect browser compatibility by checking the user agent and redirects to an error page if it's not compatible. + // When running in headless mode the user agent string contains "HeadlessChrome" which Westpac detects as incompatible, + // so we'll replace the user agent string with a compatible one. + await page.setUserAgent( + (await page.browser().userAgent()).replace("HeadlessChrome", "Chrome") + ); + await page.goto( "https://banking.westpac.com.au/wbc/banking/handler?TAM_OP=login&segment=personal&logout=false" ); diff --git a/packages/westpac-au/src/sync/syncTransactions.ts b/packages/westpac-au/src/sync/syncTransactions.ts index b36d26f..95302e7 100644 --- a/packages/westpac-au/src/sync/syncTransactions.ts +++ b/packages/westpac-au/src/sync/syncTransactions.ts @@ -91,8 +91,8 @@ export const syncTransactions = async ( const outputFilePath = await exportTransactions( page, params.westpacAccount.accountName, - params.options.startDate, - params.options.endDate, + startDate, + endDate, undefined, { debug: params.options.debug || false,