diff --git a/src/flows/DesktopFlow.ts b/src/flows/DesktopFlow.ts index 02d3547..3c74e52 100644 --- a/src/flows/DesktopFlow.ts +++ b/src/flows/DesktopFlow.ts @@ -43,9 +43,11 @@ export class DesktopFlow { * @throws {Error} If critical operation fails (login, browser init) * * @example + * ```typescript * const flow = new DesktopFlow(bot) * const result = await flow.run(account) - * console.log(`Collected ${result.collectedPoints} points`) + * // result.collectedPoints contains points earned + * ``` */ async run(account: Account): Promise { this.bot.log(false, 'DESKTOP-FLOW', 'Starting desktop automation flow') diff --git a/src/flows/MobileFlow.ts b/src/flows/MobileFlow.ts index 8f85548..477dc5c 100644 --- a/src/flows/MobileFlow.ts +++ b/src/flows/MobileFlow.ts @@ -46,9 +46,11 @@ export class MobileFlow { * @throws {Error} If critical operation fails (login, OAuth) * * @example + * ```typescript * const flow = new MobileFlow(bot) * const result = await flow.run(account) - * console.log(`Mobile: ${result.collectedPoints} points`) + * // result.collectedPoints contains mobile points earned + * ``` */ async run( account: Account, diff --git a/src/index.ts b/src/index.ts index 2541074..522f1c6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,24 +1,12 @@ -// ------------------------------- -// REFACTORING STATUS: COMPLETED ✅ -// ------------------------------- -// Successfully modularized into separate flow modules: -// ✅ DesktopFlow.ts (Desktop automation logic) - INTEGRATED -// ✅ MobileFlow.ts (Mobile automation logic) - INTEGRATED -// ✅ SummaryReporter.ts (Report generation) - INTEGRATED -// This improved testability and maintainability by 31% code reduction. -// ------------------------------- - -import { spawn } from 'child_process' +import { spawn } from 'child_process' import type { Worker } from 'cluster' import cluster from 'cluster' import fs from 'fs' import path from 'path' import type { Page } from 'playwright' import { createInterface } from 'readline' - import BrowserFunc from './browser/BrowserFunc' import BrowserUtil from './browser/BrowserUtil' - import Axios from './util/Axios' import { detectBanReason } from './util/BanDetector' import Humanizer from './util/Humanizer' @@ -255,15 +243,18 @@ export class MicrosoftRewardsBot { } private getVersion(): string { + const DEFAULT_VERSION = '2.56.0' try { const pkgPath = path.join(__dirname, '../', 'package.json') if (fs.existsSync(pkgPath)) { const raw = fs.readFileSync(pkgPath, 'utf-8') const pkg = JSON.parse(raw) - return pkg.version || '2.51.0' + return pkg.version || DEFAULT_VERSION } - } catch { /* ignore */ } - return '2.51.0' + } catch (error) { + // Ignore: Fall back to default version if package.json is unavailable + } + return DEFAULT_VERSION } // Return summaries (used when clusters==1) @@ -652,7 +643,7 @@ export class MicrosoftRewardsBot { const { ConclusionWebhook } = await import('./util/ConclusionWebhook') await ConclusionWebhook( this.config, - '🚫 Ban Detected', + '🚫 Ban Detected', `**Account:** ${email}\n**Reason:** ${reason || 'detected by heuristics'}`, undefined, DISCORD.COLOR_RED diff --git a/src/util/Load.ts b/src/util/Load.ts index 281f670..e2de791 100644 --- a/src/util/Load.ts +++ b/src/util/Load.ts @@ -2,15 +2,10 @@ import { BrowserFingerprintWithHeaders } from 'fingerprint-generator' import fs from 'fs' import path from 'path' import { BrowserContext, Cookie } from 'rebrowser-playwright' - import { Account } from '../interface/Account' import { Config, ConfigBrowser, ConfigSaveFingerprint, ConfigScheduling } from '../interface/Config' import { Util } from './Utils' - - - - const utils = new Util() let configCache: Config diff --git a/src/util/Logger.ts b/src/util/Logger.ts index f0ae6f0..92c247c 100644 --- a/src/util/Logger.ts +++ b/src/util/Logger.ts @@ -1,6 +1,5 @@ import axios from 'axios' import chalk from 'chalk' - import { DISCORD, TIMEOUTS } from '../constants' import { sendErrorReport } from './ErrorReportingWebhook' import { loadConfig } from './Load' diff --git a/src/util/UserAgent.ts b/src/util/UserAgent.ts index 494f721..65554ac 100644 --- a/src/util/UserAgent.ts +++ b/src/util/UserAgent.ts @@ -1,11 +1,9 @@ import axios from 'axios' import { BrowserFingerprintWithHeaders } from 'fingerprint-generator' - +import { Architecture, ChromeVersion, EdgeVersion, Platform } from '../interface/UserAgentUtil' import { log } from './Logger' import { Retry } from './Retry' -import { Architecture, ChromeVersion, EdgeVersion, Platform } from '../interface/UserAgentUtil' - interface UserAgentMetadata { mobile: boolean isMobile: boolean