feat: Centralize browser instance creation to eliminate duplication in Desktop and Mobile flows

fix: Update error message for HTTP 400 checks to English
refactor: Improve logging for network idle wait timeout in Workers
fix: Initialize lastError in Axios client to prevent undefined errors
chore: Update tsconfig to include path mappings for better module resolution
This commit is contained in:
2025-11-09 17:56:46 +01:00
parent 56aacd3667
commit 9fb5911fa2
10 changed files with 101 additions and 38 deletions

View File

@@ -12,6 +12,7 @@
import type { MicrosoftRewardsBot } from '../index'
import type { Account } from '../interface/Account'
import { createBrowserInstance } from '../util/BrowserFactory'
import { saveSessionData } from '../util/Load'
export interface DesktopFlowResult {
@@ -34,11 +35,8 @@ export class DesktopFlow {
async run(account: Account): Promise<DesktopFlowResult> {
this.bot.log(false, 'DESKTOP-FLOW', 'Starting desktop automation flow')
// FIXED: Use proper typed access instead of unsafe type assertion
const browserModule = await import('../browser/Browser')
const Browser = browserModule.default
const browserInstance = new Browser(this.bot)
const browser = await browserInstance.createBrowser(account.proxy, account.email)
// IMPROVED: Use centralized browser factory to eliminate duplication
const browser = await createBrowserInstance(this.bot, account.proxy, account.email)
let keepBrowserOpen = false

View File

@@ -13,6 +13,7 @@
import type { MicrosoftRewardsBot } from '../index'
import type { Account } from '../interface/Account'
import { createBrowserInstance } from '../util/BrowserFactory'
import { saveSessionData } from '../util/Load'
import { MobileRetryTracker } from '../util/MobileRetryTracker'
@@ -40,11 +41,8 @@ export class MobileFlow {
): Promise<MobileFlowResult> {
this.bot.log(true, 'MOBILE-FLOW', 'Starting mobile automation flow')
// FIXED: Use proper typed access instead of unsafe type assertion
const browserModule = await import('../browser/Browser')
const Browser = browserModule.default
const browserInstance = new Browser(this.bot)
const browser = await browserInstance.createBrowser(account.proxy, account.email)
// IMPROVED: Use centralized browser factory to eliminate duplication
const browser = await createBrowserInstance(this.bot, account.proxy, account.email)
let keepBrowserOpen = false
let browserClosed = false