sfiledl 2.2.0 → 2.2.2

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.
package/build/lib.cjs CHANGED
@@ -672,7 +672,10 @@ class InputValidator {
672
672
  return sanitized.slice(0, maxLength);
673
673
  }
674
674
  static validateOptions(options) {
675
- if (options && typeof options !== 'object') {
675
+ if (options === undefined || options === null) {
676
+ return;
677
+ }
678
+ if (typeof options !== 'object') {
676
679
  throw new ValidationError('Options must be an object or undefined', {
677
680
  received: typeof options,
678
681
  });
@@ -680,7 +683,7 @@ class InputValidator {
680
683
  const opts = options;
681
684
  const numericFields = ['timeout', 'retries', 'retryDelay', 'downloadButtonTimeout'];
682
685
  for (const field of numericFields) {
683
- if (field in opts && typeof opts[field] !== 'number') {
686
+ if (field in opts && opts[field] !== undefined && typeof opts[field] !== 'number') {
684
687
  throw new ValidationError(`Option '${field}' must be a number`, {
685
688
  field,
686
689
  received: typeof opts[field],
@@ -690,7 +693,7 @@ class InputValidator {
690
693
  }
691
694
  const booleanFields = ['headless', 'debug', 'saveDebugArtifacts'];
692
695
  for (const field of booleanFields) {
693
- if (field in opts && typeof opts[field] !== 'boolean') {
696
+ if (field in opts && opts[field] !== undefined && typeof opts[field] !== 'boolean') {
694
697
  throw new ValidationError(`Option '${field}' must be a boolean`, {
695
698
  field,
696
699
  received: typeof opts[field],
@@ -698,6 +701,23 @@ class InputValidator {
698
701
  });
699
702
  }
700
703
  }
704
+ const stringFields = ['correlationId', 'logFile', 'userAgent'];
705
+ for (const field of stringFields) {
706
+ if (field in opts && opts[field] !== undefined && typeof opts[field] !== 'string') {
707
+ throw new ValidationError(`Option '${field}' must be a string`, {
708
+ field,
709
+ received: typeof opts[field],
710
+ value: opts[field],
711
+ });
712
+ }
713
+ }
714
+ if ('onProgress' in opts &&
715
+ opts['onProgress'] !== undefined &&
716
+ typeof opts['onProgress'] !== 'function') {
717
+ throw new ValidationError(`Option 'onProgress' must be a function`, {
718
+ received: typeof opts['onProgress'],
719
+ });
720
+ }
701
721
  }
702
722
  }
703
723
 
package/build/lib.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.cjs","sources":["../lib/errors/base.ts","../lib/errors/errors.ts","../lib/config/defaults.ts","../lib/browser/page-interactions.ts","../lib/utils/helpers.ts","../lib/browser/browser-manager.ts","../lib/utils/logger.ts","../lib/config/schema.ts","../lib/core/validator.ts","../lib/core/downloader.ts","../lib/utils/result.ts"],"sourcesContent":["export abstract class AppError extends Error {\n\tpublic readonly timestamp: string\n\tpublic readonly context: Readonly<Record<string, unknown>>\n\tpublic readonly code: string\n\tpublic readonly retryable: boolean\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: string,\n\t\tretryable: boolean = false,\n\t\tcontext?: Record<string, unknown>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = this.constructor.name\n\t\tthis.code = code\n\t\tthis.retryable = retryable\n\t\tthis.timestamp = new Date().toISOString()\n\t\tthis.context = context ? Object.freeze({ ...context }) : Object.freeze({})\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, this.constructor)\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\ttoJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tretryable: this.retryable,\n\t\t\ttimestamp: this.timestamp,\n\t\t\tcontext: this.context,\n\t\t\tstack: process.env['NODE_ENV'] === 'development' ? this.stack : undefined,\n\t\t}\n\t}\n\ttoString(): string {\n\t\treturn `${this.name} [${this.code}]: ${this.message}`\n\t}\n\tisCode(code: string): boolean {\n\t\treturn this.code === code\n\t}\n\tisRetryable(): boolean {\n\t\treturn this.retryable\n\t}\n}\n","import { AppError } from './base.js'\nexport class ValidationError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'VALIDATION_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class NetworkError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'NETWORK_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class FileError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'FILE_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class BrowserError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'BROWSER_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport function isAppError(err: unknown): err is AppError {\n\treturn err instanceof AppError\n}\nexport function isRetryableError(err: unknown): boolean {\n\treturn isAppError(err) && err.retryable\n}\nexport function isErrorWithCode(err: unknown, code: string): boolean {\n\treturn isAppError(err) && err.code === code\n}\n","export const DEFAULTS = {\n\tuserAgent:\n\t\t'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',\n\theadless: true,\n\ttimeout: 60000,\n\tdownloadButtonTimeout: 30000,\n\tfallbackWaitMs: 3000,\n\tretries: 3,\n\tretryDelay: 1000,\n\tmaxRetryDelay: 30000,\n\tsaveDebugArtifacts: true,\n\tmaxFilenameLength: 255,\n\tsanitizeReplacement: '_',\n} as const\nexport type Defaults = typeof DEFAULTS\n","import { Page } from 'playwright'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError } from '../errors/index.js'\nexport class SfilePageInteractions {\n\tconstructor(\n\t\tprivate page: Page,\n\t\tprivate logger: Logger,\n\t) {}\n\tasync waitForDownloadButton(timeout: number): Promise<void> {\n\t\tthis.logger.debug('Waiting for #download button', { timeout })\n\t\tconst button = this.page.locator('#download')\n\t\tawait button.waitFor({ state: 'visible', timeout })\n\t\tthis.logger.debug('Button is visible, checking if active')\n\t\tawait this.page.waitForFunction(\n\t\t\t() => {\n\t\t\t\tconst btn = document.querySelector('#download') as HTMLAnchorElement | null\n\t\t\t\tif (!btn) return false\n\t\t\t\tconst href = btn.getAttribute('href')\n\t\t\t\tconst style = window.getComputedStyle(btn)\n\t\t\t\tconst isDisabled =\n\t\t\t\t\tbtn.hasAttribute('disabled') ||\n\t\t\t\t\tbtn.getAttribute('aria-disabled') === 'true' ||\n\t\t\t\t\tbtn.classList.contains('disabled')\n\t\t\t\treturn !!(\n\t\t\t\t\thref &&\n\t\t\t\t\thref !== '#' &&\n\t\t\t\t\thref.trim() !== '' &&\n\t\t\t\t\tstyle.pointerEvents !== 'none' &&\n\t\t\t\t\t!isDisabled\n\t\t\t\t)\n\t\t\t},\n\t\t\t{ timeout },\n\t\t)\n\t\tthis.logger.debug('Download button is active and ready')\n\t}\n\tasync extractIntermediateUrl(): Promise<string> {\n\t\tthis.logger.debug('Extracting href from #download button')\n\t\ttry {\n\t\t\tconst href = await this.page.$eval('#download', (el) => {\n\t\t\t\tconst anchor = el as HTMLAnchorElement\n\t\t\t\treturn anchor.href\n\t\t\t})\n\t\t\tif (!href || href === '#' || href.trim() === '') {\n\t\t\t\tthrow new NetworkError('Download button href is empty or invalid', { href })\n\t\t\t}\n\t\t\treturn href\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof Error && err.message?.includes('Element not found')) {\n\t\t\t\tthrow new NetworkError('Download button (#download) not found in page', {\n\t\t\t\t\tselector: '#download',\n\t\t\t\t\toriginalError: err.message,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthrow err\n\t\t}\n\t}\n}\n","export function sanitizeFilename(name: string, replacement = '_'): string {\n\tconst safeName = name.replace(/\\.\\.[\\\\/]/g, '')\n\tconst sanitized = safeName\n\t\t.replace(/[<>:\"/\\\\|?*\\x00-\\x1F]/g, replacement)\n\t\t.replace(new RegExp(`${replacement}+`, 'g'), replacement)\n\t\t.trim()\n\tconst maxLength = 255\n\tconst trimmed = sanitized.slice(0, maxLength)\n\treturn trimmed || `file${replacement}bin`\n}\nexport const sleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms))\nexport function safeStringify(value: unknown, indent = 0): string {\n\ttry {\n\t\tconst seen = new WeakSet()\n\t\treturn JSON.stringify(\n\t\t\tvalue,\n\t\t\t(_key, val) => {\n\t\t\t\tif (typeof val === 'object' && val !== null) {\n\t\t\t\t\tif (seen.has(val)) return '[Circular]'\n\t\t\t\t\tseen.add(val)\n\t\t\t\t}\n\t\t\t\tif (typeof val === 'bigint') return val.toString() + 'n'\n\t\t\t\tif (val instanceof Error) {\n\t\t\t\t\treturn { name: val.name, message: val.message, stack: val.stack }\n\t\t\t\t}\n\t\t\t\treturn val\n\t\t\t},\n\t\t\tindent,\n\t\t)\n\t} catch {\n\t\treturn '[unserializable]'\n\t}\n}\nexport function extractFilenameFromContentDisposition(header: string | undefined): string | null {\n\tif (!header) return null\n\tconst encodedMatch = header.match(/filename\\*=UTF-8''([^;\\n\"]+)/i)\n\tif (encodedMatch?.[1]) {\n\t\ttry {\n\t\t\treturn decodeURIComponent(encodedMatch[1])\n\t\t} catch {}\n\t}\n\tconst quotedMatch = header.match(/filename\\s*=\\s*\"([^\"]+)\"/i)\n\tif (quotedMatch?.[1]) return quotedMatch[1]\n\tconst plainMatch = header.match(/filename\\s*=\\s*([^;,\\n\"]+)/i)\n\tif (plainMatch?.[1]) return plainMatch[1].trim()\n\treturn null\n}\nexport function calculateRetryDelay(\n\tattempt: number,\n\tbaseDelayMs: number,\n\tmaxDelayMs = 30000,\n): number {\n\tconst exponential = baseDelayMs * Math.pow(2, attempt - 1)\n\tconst jitter = Math.random() * 0.3 * exponential\n\treturn Math.min(exponential + jitter, maxDelayMs)\n}\nexport function isError(value: unknown): value is Error {\n\treturn (\n\t\tvalue instanceof Error ||\n\t\t(typeof value === 'object' && value !== null && 'message' in value)\n\t)\n}\n","import { chromium, Browser, BrowserContext, Page, Download, Response } from 'playwright'\nimport * as fs from 'fs/promises'\nimport path from 'path'\nimport os from 'os'\nimport { Logger } from '../utils/logger.js'\nimport { BrowserError, NetworkError } from '../errors/index.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { SfilePageInteractions } from './page-interactions.js'\nimport { sleep, extractFilenameFromContentDisposition } from '../utils/helpers.js'\nexport interface BrowserManagerOptions {\n\theadless: boolean\n\tuserAgent: string\n\ttimeout: number\n\tdebug: boolean\n\tdownloadButtonTimeout?: number\n}\nexport class BrowserManager {\n\tprivate browser: Browser | null = null\n\tprivate context: BrowserContext | null = null\n\tprivate page: Page | null = null\n\tprivate interactions: SfilePageInteractions | null = null\n\tprivate debugDir: string | null = null\n\tprivate readonly stageHistory: Array<{ stage: string; ts: number }> = []\n\tconstructor(\n\t\tprivate logger: Logger,\n\t\tprivate opts: BrowserManagerOptions,\n\t) {}\n\tprivate trackStage(stage: string): void {\n\t\tthis.stageHistory.push({ stage, ts: Date.now() })\n\t}\n\tasync launch(): Promise<void> {\n\t\tconst stage = 'launch'\n\t\tthis.trackStage(stage)\n\t\ttry {\n\t\t\tthis.logger.info('Launching browser', { headless: this.opts.headless })\n\t\t\tthis.browser = await chromium.launch({\n\t\t\t\theadless: this.opts.headless,\n\t\t\t\targs: [\n\t\t\t\t\t'--no-sandbox',\n\t\t\t\t\t'--disable-setuid-sandbox',\n\t\t\t\t\t'--disable-dev-shm-usage',\n\t\t\t\t\t'--disable-accelerated-2d-canvas',\n\t\t\t\t\t'--no-first-run',\n\t\t\t\t\t'--no-zygote',\n\t\t\t\t],\n\t\t\t})\n\t\t\tthis.context = await this.browser.newContext({\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t\tacceptDownloads: true,\n\t\t\t\tlocale: 'en-US',\n\t\t\t\ttimezoneId: 'UTC',\n\t\t\t\tviewport: { width: 1280, height: 720 },\n\t\t\t})\n\t\t\tawait this.context.addCookies([\n\t\t\t\t{\n\t\t\t\t\tname: 'safe_link_counter',\n\t\t\t\t\tvalue: '1',\n\t\t\t\t\tdomain: '.sfile.co',\n\t\t\t\t\tpath: '/',\n\t\t\t\t\texpires: Math.floor(Date.now() / 1000) + 3600,\n\t\t\t\t},\n\t\t\t])\n\t\t\tthis.page = await this.context.newPage()\n\t\t\tthis.interactions = new SfilePageInteractions(this.page, this.logger)\n\t\t\tif (this.opts.debug) {\n\t\t\t\tthis.setupDebugListeners()\n\t\t\t}\n\t\t\tthis.logger.info('Browser ready')\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new BrowserError(`Failed to launch browser: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t})\n\t\t}\n\t}\n\tprivate setupDebugListeners(): void {\n\t\tif (!this.page) return\n\t\tthis.page.on('console', (msg) => {\n\t\t\tconst type = msg.type()\n\t\t\tconst text = msg.text()\n\t\t\tif (type === 'error') {\n\t\t\t\tthis.logger.error(`[console] ${text}`, { location: msg.location() })\n\t\t\t} else if (type === 'warning') {\n\t\t\t\tthis.logger.warn(`[console] ${text}`)\n\t\t\t} else if (type === 'debug') {\n\t\t\t\tthis.logger.debug(`[console] ${text}`)\n\t\t\t}\n\t\t})\n\t\tthis.page.on('pageerror', (err) => {\n\t\t\tthis.logger.error('[pageerror]', undefined, err)\n\t\t})\n\t\tthis.page.on('requestfailed', (req) => {\n\t\t\tconst failure = req.failure()\n\t\t\tthis.logger.warn('[requestfailed]', {\n\t\t\t\turl: req.url(),\n\t\t\t\tmethod: req.method(),\n\t\t\t\terror: failure?.errorText,\n\t\t\t})\n\t\t})\n\t}\n\tasync goto(\n\t\turl: string,\n\t\twaitUntil: 'load' | 'networkidle' | 'commit' | 'domcontentloaded' = 'networkidle',\n\t): Promise<void> {\n\t\tconst stage = 'navigation'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\ttry {\n\t\t\tthis.logger.debug(`Navigating to ${url}`, { waitUntil, timeout: this.opts.timeout })\n\t\t\tawait this.page.goto(url, { waitUntil, timeout: this.opts.timeout })\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Navigation failed: ${err.message}`, {\n\t\t\t\turl,\n\t\t\t\tstage,\n\t\t\t\twaitUntil,\n\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync waitForDownloadButton(): Promise<void> {\n\t\tconst stage = 'waitForButton'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\tconst timeout = this.opts.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout\n\t\ttry {\n\t\t\tawait this.interactions.waitForDownloadButton(timeout)\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to wait for download button: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\ttimeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync getIntermediateUrl(): Promise<string> {\n\t\tconst stage = 'extractUrl'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\ttry {\n\t\t\tconst url = await this.interactions.extractIntermediateUrl()\n\t\t\tthis.logger.debug('Intermediate URL extracted', { url })\n\t\t\treturn url\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to extract intermediate URL: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync startDownloadAndWait(autoUrl: string): Promise<Download | null> {\n\t\tconst stage = 'downloadWait'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tconst downloadPromise = this.page\n\t\t\t.waitForEvent('download', { timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.debug('Download event timeout', {\n\t\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t\treturn null\n\t\t\t})\n\t\tthis.logger.debug('Navigating to auto download URL', { url: autoUrl })\n\t\tawait this.page\n\t\t\t.goto(autoUrl, { waitUntil: 'commit', timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.warn('Navigation to auto URL failed, continuing anyway', {\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t})\n\t\tconst download = await downloadPromise\n\t\tif (download) {\n\t\t\tthis.logger.info('Download event captured')\n\t\t\treturn download\n\t\t}\n\t\tthis.logger.debug('No download event captured within timeout')\n\t\treturn null\n\t}\n\tasync fallbackCollectFileResponse(): Promise<{ buffer: Buffer; filename: string } | null> {\n\t\tconst stage = 'fallbackIntercept'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tthis.logger.info('Falling back to response interception')\n\t\tconst responses: Response[] = []\n\t\tconst handler = (res: Response) => responses.push(res)\n\t\tthis.page.on('response', handler)\n\t\tawait sleep(DEFAULTS.fallbackWaitMs)\n\t\tthis.page.off('response', handler)\n\t\tconst fileResponse = [...responses].reverse().find((r) => {\n\t\t\tconst headers = r.headers()\n\t\t\tconst disposition = headers['content-disposition']\n\t\t\tconst contentType = headers['content-type']\n\t\t\tconst url = r.url()\n\t\t\treturn (\n\t\t\t\t(disposition && disposition.includes('attachment')) ||\n\t\t\t\turl.includes('/downloadfile/') ||\n\t\t\t\t(contentType &&\n\t\t\t\t\t!contentType.startsWith('text/html') &&\n\t\t\t\t\t!contentType.startsWith('application/json'))\n\t\t\t)\n\t\t})\n\t\tif (!fileResponse) {\n\t\t\tthis.logger.debug('No suitable file response found in fallback', {\n\t\t\t\tresponseCount: responses.length,\n\t\t\t\tsampleUrls: responses.slice(0, 3).map((r) => r.url()),\n\t\t\t})\n\t\t\treturn null\n\t\t}\n\t\ttry {\n\t\t\tconst buffer = await fileResponse.body()\n\t\t\tlet filename = extractFilenameFromContentDisposition(\n\t\t\t\tfileResponse.headers()['content-disposition'],\n\t\t\t)\n\t\t\tif (!filename) {\n\t\t\t\tconst urlParts = fileResponse.url().split('/')\n\t\t\t\tfilename = urlParts[urlParts.length - 1]?.split('?')[0] || 'file.bin'\n\t\t\t}\n\t\t\tfilename = filename.replace(/[<>:\"/\\\\|?*]/g, '_')\n\t\t\tthis.logger.info('Fallback response captured', {\n\t\t\t\tfilename,\n\t\t\t\tsize: buffer.length,\n\t\t\t\tcontentType: fileResponse.headers()['content-type'],\n\t\t\t})\n\t\t\treturn { buffer, filename }\n\t\t} catch (err: any) {\n\t\t\tthis.logger.error('Failed to read fallback response body', { error: err.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tasync saveDebugArtifacts(errorMessage: string): Promise<string | null> {\n\t\tif (!this.opts.debug || !this.page) return null\n\t\ttry {\n\t\t\tthis.debugDir = path.join(\n\t\t\t\tos.tmpdir(),\n\t\t\t\t`sfile_debug_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,\n\t\t\t)\n\t\t\tawait fs.mkdir(this.debugDir, { recursive: true })\n\t\t\tconst tasks: Promise<void>[] = [\n\t\t\t\tthis.page\n\t\t\t\t\t.screenshot({\n\t\t\t\t\t\tpath: path.join(this.debugDir, 'error.png'),\n\t\t\t\t\t\tfullPage: true,\n\t\t\t\t\t})\n\t\t\t\t\t.then(() => {}),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.html'), await this.page.content()),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.txt'), errorMessage),\n\t\t\t\tfs.writeFile(\n\t\t\t\t\tpath.join(this.debugDir, 'stages.json'),\n\t\t\t\t\tJSON.stringify(this.stageHistory, null, 2),\n\t\t\t\t),\n\t\t\t]\n\t\t\tawait Promise.all(tasks)\n\t\t\tthis.logger.info('Debug artifacts saved', { debugDir: this.debugDir })\n\t\t\treturn this.debugDir\n\t\t} catch (e: any) {\n\t\t\tthis.logger.error('Failed to save debug artifacts', { error: e.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tprivate async handleStageError(stage: string, error: any): Promise<void> {\n\t\tif (this.opts.debug) {\n\t\t\tawait this.saveDebugArtifacts(\n\t\t\t\t`Error at stage \"${stage}\": ${error?.message || 'Unknown error'}`,\n\t\t\t)\n\t\t}\n\t}\n\tasync close(): Promise<void> {\n\t\tconst closePromises = [\n\t\t\tthis.page?.close().catch(() => {}),\n\t\t\tthis.context?.close().catch(() => {}),\n\t\t\tthis.browser?.close().catch(() => {}),\n\t\t].filter(Boolean) as Promise<void>[]\n\t\tawait Promise.all(closePromises)\n\t\tthis.logger.debug('Browser closed', { stages: this.stageHistory.length })\n\t}\n\tasync getPage(): Promise<Page | null> {\n\t\treturn this.page\n\t}\n\tgetDebugDir(): string | null {\n\t\treturn this.debugDir\n\t}\n\tgetStageHistory(): ReadonlyArray<{ stage: string; ts: number }> {\n\t\treturn [...this.stageHistory]\n\t}\n}\n","import { createWriteStream, type WriteStream } from 'fs'\nimport { safeStringify } from './helpers.js'\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error'\nexport interface LoggerOptions {\n\tdebugMode?: boolean\n\tcorrelationId?: string\n\tlogFile?: string\n\tprefix?: string\n}\nexport class Logger {\n\tprivate minLevel: LogLevel\n\tprivate correlationId: string | undefined\n\tprivate fileStream: WriteStream | null = null\n\tprivate prefix: string\n\tconstructor(options: LoggerOptions = {}) {\n\t\tthis.minLevel = options.debugMode ? 'debug' : 'info'\n\t\tthis.correlationId = options.correlationId\n\t\tthis.prefix = options.prefix || ''\n\t\tif (options.logFile) {\n\t\t\tthis.fileStream = createWriteStream(options.logFile, { flags: 'a' })\n\t\t}\n\t}\n\tsetCorrelationId(id: string): void {\n\t\tthis.correlationId = id\n\t}\n\tsetDebug(enabled: boolean): void {\n\t\tthis.minLevel = enabled ? 'debug' : 'info'\n\t}\n\tprivate levelPriority(level: LogLevel): number {\n\t\treturn { debug: 0, info: 1, warn: 2, error: 3 }[level]\n\t}\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn this.levelPriority(level) >= this.levelPriority(this.minLevel)\n\t}\n\tprivate format(level: LogLevel, message: string, context?: unknown): string {\n\t\tconst ts = new Date().toISOString()\n\t\tconst corr = this.correlationId ? ` [${this.correlationId}]` : ''\n\t\tconst prefix = this.prefix ? ` [${this.prefix}]` : ''\n\t\tconst ctx = context ? ` | ${safeStringify(context)}` : ''\n\t\treturn `[${ts}]${corr}${prefix} ${level.toUpperCase()}: ${message}${ctx}`\n\t}\n\tprivate write(level: LogLevel, message: string, context?: unknown): void {\n\t\tif (!this.shouldLog(level)) return\n\t\tconst formatted = this.format(level, message, context)\n\t\tconst consoleMethod = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log'\n\t\tconsole[consoleMethod](formatted)\n\t\tif (this.fileStream?.writable) {\n\t\t\tthis.fileStream.write(formatted + '\\n')\n\t\t}\n\t}\n\tdebug(msg: string, ctx?: unknown): void {\n\t\tthis.write('debug', msg, ctx)\n\t}\n\tinfo(msg: string, ctx?: unknown): void {\n\t\tthis.write('info', msg, ctx)\n\t}\n\twarn(msg: string, ctx?: unknown): void {\n\t\tthis.write('warn', msg, ctx)\n\t}\n\terror(msg: string, ctx?: unknown, err?: Error): void {\n\t\tlet errorCtx: unknown\n\t\tif (err) {\n\t\t\tconst baseObj =\n\t\t\t\tctx && typeof ctx === 'object' && ctx !== null\n\t\t\t\t\t? { ...(ctx as Record<string, unknown>) }\n\t\t\t\t\t: {}\n\t\t\terrorCtx = {\n\t\t\t\t...baseObj,\n\t\t\t\terror: { name: err.name, message: err.message },\n\t\t\t}\n\t\t} else {\n\t\t\terrorCtx = ctx\n\t\t}\n\t\tthis.write('error', msg, errorCtx)\n\t}\n\tchild(prefix: string): Logger {\n\t\tconst childOptions: LoggerOptions = {\n\t\t\tdebugMode: this.minLevel === 'debug',\n\t\t\t...(this.correlationId !== undefined && { correlationId: this.correlationId }),\n\t\t\tprefix: this.prefix ? `${this.prefix}:${prefix}` : prefix,\n\t\t}\n\t\tconst child = new Logger(childOptions)\n\t\tif (this.fileStream) {\n\t\t\t;(child as any).fileStream = this.fileStream\n\t\t}\n\t\treturn child\n\t}\n\tasync close(): Promise<void> {\n\t\tif (this.fileStream && !this.fileStream.closed) {\n\t\t\treturn new Promise((resolve) => this.fileStream?.end(resolve))\n\t\t}\n\t}\n}\n","import { DEFAULTS } from './defaults.js'\nexport interface DownloadOptions {\n\theadless?: boolean\n\tuserAgent?: string\n\ttimeout?: number\n\tdownloadButtonTimeout?: number\n\tretries?: number\n\tretryDelay?: number\n\tonProgress?: (\n\t\tpercent: number,\n\t\ttotal: 100,\n\t\tmeta: { stage: string; message: string; attempt?: number },\n\t) => void\n\tcorrelationId?: string\n\tdebug?: boolean\n\tsaveDebugArtifacts?: boolean\n\tlogFile?: string\n\t_internal?: {\n\t\tstage?: string\n\t}\n}\nexport interface DownloadResult {\n\tfilePath: string\n\tsize: number\n\tmethod: 'direct' | 'fallback'\n\tcorrelationId?: string\n\tdurationMs?: number\n\tattempts?: number\n}\ntype NormalizedOptions = Required<\n\tOmit<DownloadOptions, 'onProgress' | 'correlationId' | '_internal' | 'logFile'>\n> & {\n\tonProgress?: DownloadOptions['onProgress']\n\tcorrelationId?: string\n\t_internal?: DownloadOptions['_internal']\n\tlogFile?: string\n}\nexport function normalizeOptions(opts?: DownloadOptions): NormalizedOptions {\n\tconst base = {\n\t\theadless: opts?.headless ?? DEFAULTS.headless,\n\t\tuserAgent: opts?.userAgent ?? DEFAULTS.userAgent,\n\t\ttimeout: opts?.timeout ?? DEFAULTS.timeout,\n\t\tdownloadButtonTimeout: opts?.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout,\n\t\tretries: opts?.retries ?? DEFAULTS.retries,\n\t\tretryDelay: opts?.retryDelay ?? DEFAULTS.retryDelay,\n\t\tdebug: opts?.debug ?? false,\n\t\tsaveDebugArtifacts: opts?.saveDebugArtifacts ?? DEFAULTS.saveDebugArtifacts,\n\t}\n\tconst optional = {\n\t\t...(opts?.onProgress !== undefined && { onProgress: opts.onProgress }),\n\t\t...(opts?.correlationId !== undefined && { correlationId: opts.correlationId }),\n\t\t...(opts?._internal !== undefined && { _internal: opts._internal }),\n\t\t...(opts?.logFile !== undefined && { logFile: opts.logFile }),\n\t}\n\treturn { ...base, ...optional } as NormalizedOptions\n}\n","import { ValidationError } from '../errors/index.js'\nimport { sanitizeFilename } from '../utils/helpers.js'\nimport { DEFAULTS } from '../config/defaults.js'\nexport class InputValidator {\n\tstatic validateUrl(\n\t\turl: unknown,\n\t\tallowedDomains: readonly string[] = ['sfile.co', 'sfile.mobi'],\n\t): asserts url is string {\n\t\tif (!url || typeof url !== 'string') {\n\t\t\tthrow new ValidationError('URL must be a non-empty string', {\n\t\t\t\treceived: typeof url,\n\t\t\t\turl,\n\t\t\t})\n\t\t}\n\t\tconst hasAllowedDomain = allowedDomains.some((domain) => url.includes(domain))\n\t\tif (!hasAllowedDomain) {\n\t\t\tthrow new ValidationError(`URL must contain one of: ${allowedDomains.join(', ')}`, {\n\t\t\t\turl,\n\t\t\t\tallowedDomains,\n\t\t\t})\n\t\t}\n\t\ttry {\n\t\t\tconst parsed = new URL(url)\n\t\t\tif (!['http:', 'https:'].includes(parsed.protocol)) {\n\t\t\t\tthrow new ValidationError('URL must use http or https protocol', {\n\t\t\t\t\turl,\n\t\t\t\t\tprotocol: parsed.protocol,\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (parseErr) {\n\t\t\tthrow new ValidationError('Invalid URL format', {\n\t\t\t\turl,\n\t\t\t\tparseError: parseErr instanceof Error ? parseErr.message : String(parseErr),\n\t\t\t})\n\t\t}\n\t}\n\tstatic validateSaveDir(dir: unknown): asserts dir is string {\n\t\tif (!dir || typeof dir !== 'string') {\n\t\t\tthrow new ValidationError('Save directory must be a non-empty string', {\n\t\t\t\treceived: typeof dir,\n\t\t\t\tdir,\n\t\t\t})\n\t\t}\n\t}\n\tstatic sanitizeFilename(name: string): string {\n\t\tconst replacement = DEFAULTS.sanitizeReplacement\n\t\tconst maxLength = DEFAULTS.maxFilenameLength\n\t\tconst sanitized = sanitizeFilename(name, replacement)\n\t\tif (!sanitized || sanitized.length === 0) {\n\t\t\tconst ext = name.includes('.') ? name.split('.').pop() : 'bin'\n\t\t\treturn `downloaded_file${ext ? '.' + ext : ''}`.slice(0, maxLength)\n\t\t}\n\t\treturn sanitized.slice(0, maxLength)\n\t}\n\tstatic validateOptions(options: unknown): void {\n\t\tif (options && typeof options !== 'object') {\n\t\t\tthrow new ValidationError('Options must be an object or undefined', {\n\t\t\t\treceived: typeof options,\n\t\t\t})\n\t\t}\n\t\tconst opts = options as Record<string, unknown>\n\t\tconst numericFields = ['timeout', 'retries', 'retryDelay', 'downloadButtonTimeout'] as const\n\t\tfor (const field of numericFields) {\n\t\t\tif (field in opts && typeof opts[field] !== 'number') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a number`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst booleanFields = ['headless', 'debug', 'saveDebugArtifacts'] as const\n\t\tfor (const field of booleanFields) {\n\t\t\tif (field in opts && typeof opts[field] !== 'boolean') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a boolean`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n","import * as path from 'path'\nimport { promises as fs } from 'fs'\nimport { randomUUID } from 'crypto'\nimport { BrowserManager } from '../browser/browser-manager.js'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError, AppError } from '../errors/index.js'\nimport { DownloadOptions, DownloadResult, normalizeOptions } from '../config/schema.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { InputValidator } from './validator.js'\nimport { sleep, calculateRetryDelay } from '../utils/helpers.js'\nfunction stripUndefined<T extends Record<string, unknown>>(obj: T): T {\n\treturn Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as T\n}\nfunction safeProgress(\n\tonProgress: unknown,\n\tpercent: number,\n\ttotal: number,\n\tmeta: Record<string, unknown>,\n): void {\n\tif (typeof onProgress === 'function') {\n\t\ttry {\n\t\t\t;(onProgress as any)(percent, total, meta)\n\t\t} catch (err) {\n\t\t\tconsole.warn('Progress callback error:', err)\n\t\t}\n\t}\n}\nasync function executeDownload(\n\turl: string,\n\tsaveDir: string,\n\topts: ReturnType<typeof normalizeOptions>,\n\tlogger: Logger,\n): Promise<DownloadResult> {\n\tconst startTime = Date.now()\n\tconst browserMgr = new BrowserManager(logger.child('BrowserManager'), {\n\t\theadless: opts.headless,\n\t\tuserAgent: opts.userAgent,\n\t\ttimeout: opts.timeout,\n\t\tdebug: opts.debug,\n\t\tdownloadButtonTimeout: opts.downloadButtonTimeout,\n\t})\n\tlet finalPath: string\n\tlet fileSize: number\n\tlet method: 'direct' | 'fallback'\n\ttry {\n\t\tlogger.info('Starting download workflow', { url })\n\t\tsafeProgress(opts.onProgress, 10, 100, {\n\t\t\tstage: 'launch',\n\t\t\tmessage: 'Launching browser',\n\t\t\tattempt: 1,\n\t\t})\n\t\tawait browserMgr.launch()\n\t\tawait browserMgr.goto(url, 'networkidle')\n\t\tsafeProgress(opts.onProgress, 30, 100, { stage: 'navigation', message: 'Page loaded' })\n\t\tawait browserMgr.waitForDownloadButton()\n\t\tsafeProgress(opts.onProgress, 50, 100, {\n\t\t\tstage: 'button',\n\t\t\tmessage: 'Download button ready',\n\t\t})\n\t\tconst intermediateUrl = await browserMgr.getIntermediateUrl()\n\t\tconst autoUrl = intermediateUrl.includes('?')\n\t\t\t? `${intermediateUrl}&auto=1`\n\t\t\t: `${intermediateUrl}?auto=1`\n\t\tlogger.debug('Triggering download', { autoUrl })\n\t\tsafeProgress(opts.onProgress, 70, 100, { stage: 'trigger', message: 'Download triggered' })\n\t\tlet download = await browserMgr.startDownloadAndWait(autoUrl)\n\t\tif (download) {\n\t\t\tconst suggested = download.suggestedFilename() || 'file.bin'\n\t\t\tconst filename = InputValidator.sanitizeFilename(suggested)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait download.saveAs(finalPath)\n\t\t\tconst stat = await fs.stat(finalPath)\n\t\t\tfileSize = stat.size\n\t\t\tmethod = 'direct'\n\t\t\tlogger.info('Saved via direct download', { path: finalPath, size: fileSize })\n\t\t} else {\n\t\t\tlogger.warn('Direct download not captured, trying fallback')\n\t\t\tconst fallback = await browserMgr.fallbackCollectFileResponse()\n\t\t\tif (!fallback) {\n\t\t\t\tthrow new NetworkError('No download event and no file response found', {\n\t\t\t\t\turl,\n\t\t\t\t\tintermediateUrl,\n\t\t\t\t\tautoUrl,\n\t\t\t\t\tstage: 'fallbackFailed',\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst { buffer, filename: rawName } = fallback\n\t\t\tconst filename = InputValidator.sanitizeFilename(rawName)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait fs.writeFile(finalPath, buffer)\n\t\t\tfileSize = buffer.length\n\t\t\tmethod = 'fallback'\n\t\t\tlogger.info('Saved via fallback', { path: finalPath, size: fileSize })\n\t\t}\n\t\tsafeProgress(opts.onProgress, 100, 100, { stage: 'complete', message: 'Download finished' })\n\t\tconst result: DownloadResult = {\n\t\t\tfilePath: finalPath,\n\t\t\tsize: fileSize,\n\t\t\tmethod,\n\t\t\tdurationMs: Date.now() - startTime,\n\t\t\tattempts: 1,\n\t\t}\n\t\tif (opts.correlationId !== undefined) {\n\t\t\tresult.correlationId = opts.correlationId\n\t\t}\n\t\treturn result\n\t} catch (err: unknown) {\n\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\tconst appError =\n\t\t\terror instanceof AppError\n\t\t\t\t? error\n\t\t\t\t: new NetworkError(error.message, {\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tsaveDir,\n\t\t\t\t\t\tcorrelationId: opts.correlationId,\n\t\t\t\t\t\toriginalError: error.message,\n\t\t\t\t\t\terrorName: error.name,\n\t\t\t\t\t})\n\t\tif (opts.saveDebugArtifacts) {\n\t\t\tconst debugPath = await browserMgr.saveDebugArtifacts(appError.message)\n\t\t\tif (debugPath) {\n\t\t\t\t;(appError as any).debugPath = debugPath\n\t\t\t\tif (appError.context && typeof appError.context === 'object') {\n\t\t\t\t\t;(appError.context as any).debugPath = debugPath\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow appError\n\t} finally {\n\t\tawait browserMgr\n\t\t\t.close()\n\t\t\t.catch((e) => logger.error('Failed to close browser', { error: e.message }))\n\t\tawait logger.close().catch((e) => console.error('Failed to close logger', e))\n\t}\n}\nexport async function downloadSfile(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<DownloadResult> {\n\tconst opts = normalizeOptions(options)\n\tconst correlationId = opts.correlationId || randomUUID()\n\ttype LoggerConstructorParams = ConstructorParameters<typeof Logger>\n\ttype LoggerOptionsType = LoggerConstructorParams[0]\n\tconst loggerOptions: LoggerOptionsType = {\n\t\tdebugMode: opts.debug,\n\t\tcorrelationId,\n\t\tprefix: 'downloadSfile',\n\t}\n\tif (opts.logFile !== undefined) {\n\t\tloggerOptions.logFile = opts.logFile\n\t}\n\tconst logger = new Logger(loggerOptions)\n\tInputValidator.validateUrl(url)\n\tInputValidator.validateSaveDir(saveDir)\n\tInputValidator.validateOptions(options)\n\tawait fs.mkdir(saveDir, { recursive: true })\n\tlet lastError: Error | undefined\n\tlet attempt = 0\n\twhile (attempt < opts.retries) {\n\t\tattempt++\n\t\ttry {\n\t\t\tlogger.info(`Download attempt ${attempt}/${opts.retries}`, { url })\n\t\t\tconst result = await executeDownload(url, saveDir, opts, logger)\n\t\t\tlogger.info(`Download succeeded`, {\n\t\t\t\tduration: result.durationMs,\n\t\t\t\tattempts: attempt,\n\t\t\t\tmethod: result.method,\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattempts: attempt,\n\t\t\t\tcorrelationId,\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tlastError = err instanceof Error ? err : new Error(String(err))\n\t\t\tconst isRetryable = lastError instanceof AppError && lastError.retryable\n\t\t\tconst isLastAttempt = attempt >= opts.retries\n\t\t\tif (!isRetryable || isLastAttempt) {\n\t\t\t\tlogger.error(`Download failed permanently`, {\n\t\t\t\t\terror: lastError.message,\n\t\t\t\t\tattempt,\n\t\t\t\t\tretryable: isRetryable,\n\t\t\t\t\tlastAttempt: isLastAttempt,\n\t\t\t\t})\n\t\t\t\tthrow lastError\n\t\t\t}\n\t\t\tconst delay = calculateRetryDelay(attempt, opts.retryDelay, DEFAULTS.maxRetryDelay)\n\t\t\tlogger.warn(`Retrying download`, {\n\t\t\t\tattempt,\n\t\t\t\tmaxAttempts: opts.retries,\n\t\t\t\tdelayMs: Math.round(delay),\n\t\t\t\terror: lastError.message,\n\t\t\t})\n\t\t\tsafeProgress(opts.onProgress, 0, 100, {\n\t\t\t\tstage: 'retry',\n\t\t\t\tmessage: `Retry ${attempt}/${opts.retries}`,\n\t\t\t\tattempt,\n\t\t\t})\n\t\t\tawait sleep(delay)\n\t\t}\n\t}\n\tthrow lastError || new Error('Download failed after all retries')\n}\nexport async function downloadSfileSafe(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\ttry {\n\t\tconst result = await downloadSfile(url, saveDir, options)\n\t\treturn { success: true, value: result }\n\t} catch (error) {\n\t\treturn { success: false, error: error as Error }\n\t}\n}\nexport function createDownloader(defaultOptions?: DownloadOptions) {\n\tconst defaults = normalizeOptions(defaultOptions)\n\treturn {\n\t\tasync download(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<DownloadResult> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfile(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\tasync downloadSafe(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfileSafe(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\twithOptions(newDefaults: Partial<DownloadOptions>) {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...newDefaults })\n\t\t\treturn createDownloader(merged as DownloadOptions)\n\t\t},\n\t}\n}\n","export type Result<T, E = Error> = { success: true; value: T } | { success: false; error: E }\nexport function ok<T, E = never>(value: T): Result<T, E> {\n\treturn { success: true, value }\n}\nexport function err<E, T = never>(error: E): Result<T, E> {\n\treturn { success: false, error }\n}\nexport function isSuccess<T, E>(result: Result<T, E>): result is { success: true; value: T } {\n\treturn result.success === true\n}\nexport function isFailure<T, E>(result: Result<T, E>): result is { success: false; error: E } {\n\treturn result.success === false\n}\nexport function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {\n\tif (result.success) {\n\t\treturn { success: true, value: fn(result.value) }\n\t}\n\treturn result\n}\nexport function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F> {\n\tif (!result.success) {\n\t\treturn { success: false, error: fn(result.error) }\n\t}\n\treturn result\n}\nexport function getOrThrow<T, E>(result: Result<T, E>): T {\n\tif (result.success) return result.value\n\tthrow result.error\n}\n"],"names":["chromium","path","os","fs","createWriteStream","randomUUID"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAM,MAAgB,QAAS,SAAQ,KAAK,CAAA;AAC3B,IAAA,SAAS;AACT,IAAA,OAAO;AACP,IAAA,IAAI;AACJ,IAAA,SAAS;AACzB,IAAA,WAAA,CACC,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AAc,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;YAC9D,OAAO,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAyB,CAAC;QAC9D,CAAC;AACD,QAAA,MAAM,YAAY,CACjB,GAAW,EACX,OAAe,EACf,WAA6B,EAAA;AAE7B,YAAA,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;YAC9D,OAAO,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAyB,CAAC;QAClE,CAAC;AACD,QAAA,WAAW,CAAC,WAAqC,EAAA;AAChD,YAAA,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;AAC9D,YAAA,OAAO,gBAAgB,CAAC,MAAyB,CAAC;QACnD,CAAC;KACD;AACF;;ACzOM,SAAU,SAAS,CAAO,MAAoB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,KAAK,IAAI;AAC/B;AACM,SAAU,SAAS,CAAO,MAAoB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,KAAK,KAAK;AAChC;AAOM,SAAU,QAAQ,CAAU,MAAoB,EAAE,EAAmB,EAAA;AAC1E,IAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACpB,QAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;IACnD;AACA,IAAA,OAAO,MAAM;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"lib.cjs","sources":["../lib/errors/base.ts","../lib/errors/errors.ts","../lib/config/defaults.ts","../lib/browser/page-interactions.ts","../lib/utils/helpers.ts","../lib/browser/browser-manager.ts","../lib/utils/logger.ts","../lib/config/schema.ts","../lib/core/validator.ts","../lib/core/downloader.ts","../lib/utils/result.ts"],"sourcesContent":["export abstract class AppError extends Error {\n\tpublic readonly timestamp: string\n\tpublic readonly context: Readonly<Record<string, unknown>>\n\tpublic readonly code: string\n\tpublic readonly retryable: boolean\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: string,\n\t\tretryable: boolean = false,\n\t\tcontext?: Record<string, unknown>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = this.constructor.name\n\t\tthis.code = code\n\t\tthis.retryable = retryable\n\t\tthis.timestamp = new Date().toISOString()\n\t\tthis.context = context ? Object.freeze({ ...context }) : Object.freeze({})\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, this.constructor)\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\ttoJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tretryable: this.retryable,\n\t\t\ttimestamp: this.timestamp,\n\t\t\tcontext: this.context,\n\t\t\tstack: process.env['NODE_ENV'] === 'development' ? this.stack : undefined,\n\t\t}\n\t}\n\ttoString(): string {\n\t\treturn `${this.name} [${this.code}]: ${this.message}`\n\t}\n\tisCode(code: string): boolean {\n\t\treturn this.code === code\n\t}\n\tisRetryable(): boolean {\n\t\treturn this.retryable\n\t}\n}\n","import { AppError } from './base.js'\nexport class ValidationError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'VALIDATION_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class NetworkError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'NETWORK_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class FileError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'FILE_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class BrowserError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'BROWSER_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport function isAppError(err: unknown): err is AppError {\n\treturn err instanceof AppError\n}\nexport function isRetryableError(err: unknown): boolean {\n\treturn isAppError(err) && err.retryable\n}\nexport function isErrorWithCode(err: unknown, code: string): boolean {\n\treturn isAppError(err) && err.code === code\n}\n","export const DEFAULTS = {\n\tuserAgent:\n\t\t'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',\n\theadless: true,\n\ttimeout: 60000,\n\tdownloadButtonTimeout: 30000,\n\tfallbackWaitMs: 3000,\n\tretries: 3,\n\tretryDelay: 1000,\n\tmaxRetryDelay: 30000,\n\tsaveDebugArtifacts: true,\n\tmaxFilenameLength: 255,\n\tsanitizeReplacement: '_',\n} as const\nexport type Defaults = typeof DEFAULTS\n","import { Page } from 'playwright'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError } from '../errors/index.js'\nexport class SfilePageInteractions {\n\tconstructor(\n\t\tprivate page: Page,\n\t\tprivate logger: Logger,\n\t) {}\n\tasync waitForDownloadButton(timeout: number): Promise<void> {\n\t\tthis.logger.debug('Waiting for #download button', { timeout })\n\t\tconst button = this.page.locator('#download')\n\t\tawait button.waitFor({ state: 'visible', timeout })\n\t\tthis.logger.debug('Button is visible, checking if active')\n\t\tawait this.page.waitForFunction(\n\t\t\t() => {\n\t\t\t\tconst btn = document.querySelector('#download') as HTMLAnchorElement | null\n\t\t\t\tif (!btn) return false\n\t\t\t\tconst href = btn.getAttribute('href')\n\t\t\t\tconst style = window.getComputedStyle(btn)\n\t\t\t\tconst isDisabled =\n\t\t\t\t\tbtn.hasAttribute('disabled') ||\n\t\t\t\t\tbtn.getAttribute('aria-disabled') === 'true' ||\n\t\t\t\t\tbtn.classList.contains('disabled')\n\t\t\t\treturn !!(\n\t\t\t\t\thref &&\n\t\t\t\t\thref !== '#' &&\n\t\t\t\t\thref.trim() !== '' &&\n\t\t\t\t\tstyle.pointerEvents !== 'none' &&\n\t\t\t\t\t!isDisabled\n\t\t\t\t)\n\t\t\t},\n\t\t\t{ timeout },\n\t\t)\n\t\tthis.logger.debug('Download button is active and ready')\n\t}\n\tasync extractIntermediateUrl(): Promise<string> {\n\t\tthis.logger.debug('Extracting href from #download button')\n\t\ttry {\n\t\t\tconst href = await this.page.$eval('#download', (el) => {\n\t\t\t\tconst anchor = el as HTMLAnchorElement\n\t\t\t\treturn anchor.href\n\t\t\t})\n\t\t\tif (!href || href === '#' || href.trim() === '') {\n\t\t\t\tthrow new NetworkError('Download button href is empty or invalid', { href })\n\t\t\t}\n\t\t\treturn href\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof Error && err.message?.includes('Element not found')) {\n\t\t\t\tthrow new NetworkError('Download button (#download) not found in page', {\n\t\t\t\t\tselector: '#download',\n\t\t\t\t\toriginalError: err.message,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthrow err\n\t\t}\n\t}\n}\n","export function sanitizeFilename(name: string, replacement = '_'): string {\n\tconst safeName = name.replace(/\\.\\.[\\\\/]/g, '')\n\tconst sanitized = safeName\n\t\t.replace(/[<>:\"/\\\\|?*\\x00-\\x1F]/g, replacement)\n\t\t.replace(new RegExp(`${replacement}+`, 'g'), replacement)\n\t\t.trim()\n\tconst maxLength = 255\n\tconst trimmed = sanitized.slice(0, maxLength)\n\treturn trimmed || `file${replacement}bin`\n}\nexport const sleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms))\nexport function safeStringify(value: unknown, indent = 0): string {\n\ttry {\n\t\tconst seen = new WeakSet()\n\t\treturn JSON.stringify(\n\t\t\tvalue,\n\t\t\t(_key, val) => {\n\t\t\t\tif (typeof val === 'object' && val !== null) {\n\t\t\t\t\tif (seen.has(val)) return '[Circular]'\n\t\t\t\t\tseen.add(val)\n\t\t\t\t}\n\t\t\t\tif (typeof val === 'bigint') return val.toString() + 'n'\n\t\t\t\tif (val instanceof Error) {\n\t\t\t\t\treturn { name: val.name, message: val.message, stack: val.stack }\n\t\t\t\t}\n\t\t\t\treturn val\n\t\t\t},\n\t\t\tindent,\n\t\t)\n\t} catch {\n\t\treturn '[unserializable]'\n\t}\n}\nexport function extractFilenameFromContentDisposition(header: string | undefined): string | null {\n\tif (!header) return null\n\tconst encodedMatch = header.match(/filename\\*=UTF-8''([^;\\n\"]+)/i)\n\tif (encodedMatch?.[1]) {\n\t\ttry {\n\t\t\treturn decodeURIComponent(encodedMatch[1])\n\t\t} catch {}\n\t}\n\tconst quotedMatch = header.match(/filename\\s*=\\s*\"([^\"]+)\"/i)\n\tif (quotedMatch?.[1]) return quotedMatch[1]\n\tconst plainMatch = header.match(/filename\\s*=\\s*([^;,\\n\"]+)/i)\n\tif (plainMatch?.[1]) return plainMatch[1].trim()\n\treturn null\n}\nexport function calculateRetryDelay(\n\tattempt: number,\n\tbaseDelayMs: number,\n\tmaxDelayMs = 30000,\n): number {\n\tconst exponential = baseDelayMs * Math.pow(2, attempt - 1)\n\tconst jitter = Math.random() * 0.3 * exponential\n\treturn Math.min(exponential + jitter, maxDelayMs)\n}\nexport function isError(value: unknown): value is Error {\n\treturn (\n\t\tvalue instanceof Error ||\n\t\t(typeof value === 'object' && value !== null && 'message' in value)\n\t)\n}\n","import { chromium, Browser, BrowserContext, Page, Download, Response } from 'playwright'\nimport * as fs from 'fs/promises'\nimport path from 'path'\nimport os from 'os'\nimport { Logger } from '../utils/logger.js'\nimport { BrowserError, NetworkError } from '../errors/index.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { SfilePageInteractions } from './page-interactions.js'\nimport { sleep, extractFilenameFromContentDisposition } from '../utils/helpers.js'\nexport interface BrowserManagerOptions {\n\theadless: boolean\n\tuserAgent: string\n\ttimeout: number\n\tdebug: boolean\n\tdownloadButtonTimeout?: number\n}\nexport class BrowserManager {\n\tprivate browser: Browser | null = null\n\tprivate context: BrowserContext | null = null\n\tprivate page: Page | null = null\n\tprivate interactions: SfilePageInteractions | null = null\n\tprivate debugDir: string | null = null\n\tprivate readonly stageHistory: Array<{ stage: string; ts: number }> = []\n\tconstructor(\n\t\tprivate logger: Logger,\n\t\tprivate opts: BrowserManagerOptions,\n\t) {}\n\tprivate trackStage(stage: string): void {\n\t\tthis.stageHistory.push({ stage, ts: Date.now() })\n\t}\n\tasync launch(): Promise<void> {\n\t\tconst stage = 'launch'\n\t\tthis.trackStage(stage)\n\t\ttry {\n\t\t\tthis.logger.info('Launching browser', { headless: this.opts.headless })\n\t\t\tthis.browser = await chromium.launch({\n\t\t\t\theadless: this.opts.headless,\n\t\t\t\targs: [\n\t\t\t\t\t'--no-sandbox',\n\t\t\t\t\t'--disable-setuid-sandbox',\n\t\t\t\t\t'--disable-dev-shm-usage',\n\t\t\t\t\t'--disable-accelerated-2d-canvas',\n\t\t\t\t\t'--no-first-run',\n\t\t\t\t\t'--no-zygote',\n\t\t\t\t],\n\t\t\t})\n\t\t\tthis.context = await this.browser.newContext({\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t\tacceptDownloads: true,\n\t\t\t\tlocale: 'en-US',\n\t\t\t\ttimezoneId: 'UTC',\n\t\t\t\tviewport: { width: 1280, height: 720 },\n\t\t\t})\n\t\t\tawait this.context.addCookies([\n\t\t\t\t{\n\t\t\t\t\tname: 'safe_link_counter',\n\t\t\t\t\tvalue: '1',\n\t\t\t\t\tdomain: '.sfile.co',\n\t\t\t\t\tpath: '/',\n\t\t\t\t\texpires: Math.floor(Date.now() / 1000) + 3600,\n\t\t\t\t},\n\t\t\t])\n\t\t\tthis.page = await this.context.newPage()\n\t\t\tthis.interactions = new SfilePageInteractions(this.page, this.logger)\n\t\t\tif (this.opts.debug) {\n\t\t\t\tthis.setupDebugListeners()\n\t\t\t}\n\t\t\tthis.logger.info('Browser ready')\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new BrowserError(`Failed to launch browser: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t})\n\t\t}\n\t}\n\tprivate setupDebugListeners(): void {\n\t\tif (!this.page) return\n\t\tthis.page.on('console', (msg) => {\n\t\t\tconst type = msg.type()\n\t\t\tconst text = msg.text()\n\t\t\tif (type === 'error') {\n\t\t\t\tthis.logger.error(`[console] ${text}`, { location: msg.location() })\n\t\t\t} else if (type === 'warning') {\n\t\t\t\tthis.logger.warn(`[console] ${text}`)\n\t\t\t} else if (type === 'debug') {\n\t\t\t\tthis.logger.debug(`[console] ${text}`)\n\t\t\t}\n\t\t})\n\t\tthis.page.on('pageerror', (err) => {\n\t\t\tthis.logger.error('[pageerror]', undefined, err)\n\t\t})\n\t\tthis.page.on('requestfailed', (req) => {\n\t\t\tconst failure = req.failure()\n\t\t\tthis.logger.warn('[requestfailed]', {\n\t\t\t\turl: req.url(),\n\t\t\t\tmethod: req.method(),\n\t\t\t\terror: failure?.errorText,\n\t\t\t})\n\t\t})\n\t}\n\tasync goto(\n\t\turl: string,\n\t\twaitUntil: 'load' | 'networkidle' | 'commit' | 'domcontentloaded' = 'networkidle',\n\t): Promise<void> {\n\t\tconst stage = 'navigation'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\ttry {\n\t\t\tthis.logger.debug(`Navigating to ${url}`, { waitUntil, timeout: this.opts.timeout })\n\t\t\tawait this.page.goto(url, { waitUntil, timeout: this.opts.timeout })\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Navigation failed: ${err.message}`, {\n\t\t\t\turl,\n\t\t\t\tstage,\n\t\t\t\twaitUntil,\n\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync waitForDownloadButton(): Promise<void> {\n\t\tconst stage = 'waitForButton'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\tconst timeout = this.opts.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout\n\t\ttry {\n\t\t\tawait this.interactions.waitForDownloadButton(timeout)\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to wait for download button: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\ttimeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync getIntermediateUrl(): Promise<string> {\n\t\tconst stage = 'extractUrl'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\ttry {\n\t\t\tconst url = await this.interactions.extractIntermediateUrl()\n\t\t\tthis.logger.debug('Intermediate URL extracted', { url })\n\t\t\treturn url\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to extract intermediate URL: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync startDownloadAndWait(autoUrl: string): Promise<Download | null> {\n\t\tconst stage = 'downloadWait'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tconst downloadPromise = this.page\n\t\t\t.waitForEvent('download', { timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.debug('Download event timeout', {\n\t\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t\treturn null\n\t\t\t})\n\t\tthis.logger.debug('Navigating to auto download URL', { url: autoUrl })\n\t\tawait this.page\n\t\t\t.goto(autoUrl, { waitUntil: 'commit', timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.warn('Navigation to auto URL failed, continuing anyway', {\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t})\n\t\tconst download = await downloadPromise\n\t\tif (download) {\n\t\t\tthis.logger.info('Download event captured')\n\t\t\treturn download\n\t\t}\n\t\tthis.logger.debug('No download event captured within timeout')\n\t\treturn null\n\t}\n\tasync fallbackCollectFileResponse(): Promise<{ buffer: Buffer; filename: string } | null> {\n\t\tconst stage = 'fallbackIntercept'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tthis.logger.info('Falling back to response interception')\n\t\tconst responses: Response[] = []\n\t\tconst handler = (res: Response) => responses.push(res)\n\t\tthis.page.on('response', handler)\n\t\tawait sleep(DEFAULTS.fallbackWaitMs)\n\t\tthis.page.off('response', handler)\n\t\tconst fileResponse = [...responses].reverse().find((r) => {\n\t\t\tconst headers = r.headers()\n\t\t\tconst disposition = headers['content-disposition']\n\t\t\tconst contentType = headers['content-type']\n\t\t\tconst url = r.url()\n\t\t\treturn (\n\t\t\t\t(disposition && disposition.includes('attachment')) ||\n\t\t\t\turl.includes('/downloadfile/') ||\n\t\t\t\t(contentType &&\n\t\t\t\t\t!contentType.startsWith('text/html') &&\n\t\t\t\t\t!contentType.startsWith('application/json'))\n\t\t\t)\n\t\t})\n\t\tif (!fileResponse) {\n\t\t\tthis.logger.debug('No suitable file response found in fallback', {\n\t\t\t\tresponseCount: responses.length,\n\t\t\t\tsampleUrls: responses.slice(0, 3).map((r) => r.url()),\n\t\t\t})\n\t\t\treturn null\n\t\t}\n\t\ttry {\n\t\t\tconst buffer = await fileResponse.body()\n\t\t\tlet filename = extractFilenameFromContentDisposition(\n\t\t\t\tfileResponse.headers()['content-disposition'],\n\t\t\t)\n\t\t\tif (!filename) {\n\t\t\t\tconst urlParts = fileResponse.url().split('/')\n\t\t\t\tfilename = urlParts[urlParts.length - 1]?.split('?')[0] || 'file.bin'\n\t\t\t}\n\t\t\tfilename = filename.replace(/[<>:\"/\\\\|?*]/g, '_')\n\t\t\tthis.logger.info('Fallback response captured', {\n\t\t\t\tfilename,\n\t\t\t\tsize: buffer.length,\n\t\t\t\tcontentType: fileResponse.headers()['content-type'],\n\t\t\t})\n\t\t\treturn { buffer, filename }\n\t\t} catch (err: any) {\n\t\t\tthis.logger.error('Failed to read fallback response body', { error: err.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tasync saveDebugArtifacts(errorMessage: string): Promise<string | null> {\n\t\tif (!this.opts.debug || !this.page) return null\n\t\ttry {\n\t\t\tthis.debugDir = path.join(\n\t\t\t\tos.tmpdir(),\n\t\t\t\t`sfile_debug_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,\n\t\t\t)\n\t\t\tawait fs.mkdir(this.debugDir, { recursive: true })\n\t\t\tconst tasks: Promise<void>[] = [\n\t\t\t\tthis.page\n\t\t\t\t\t.screenshot({\n\t\t\t\t\t\tpath: path.join(this.debugDir, 'error.png'),\n\t\t\t\t\t\tfullPage: true,\n\t\t\t\t\t})\n\t\t\t\t\t.then(() => {}),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.html'), await this.page.content()),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.txt'), errorMessage),\n\t\t\t\tfs.writeFile(\n\t\t\t\t\tpath.join(this.debugDir, 'stages.json'),\n\t\t\t\t\tJSON.stringify(this.stageHistory, null, 2),\n\t\t\t\t),\n\t\t\t]\n\t\t\tawait Promise.all(tasks)\n\t\t\tthis.logger.info('Debug artifacts saved', { debugDir: this.debugDir })\n\t\t\treturn this.debugDir\n\t\t} catch (e: any) {\n\t\t\tthis.logger.error('Failed to save debug artifacts', { error: e.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tprivate async handleStageError(stage: string, error: any): Promise<void> {\n\t\tif (this.opts.debug) {\n\t\t\tawait this.saveDebugArtifacts(\n\t\t\t\t`Error at stage \"${stage}\": ${error?.message || 'Unknown error'}`,\n\t\t\t)\n\t\t}\n\t}\n\tasync close(): Promise<void> {\n\t\tconst closePromises = [\n\t\t\tthis.page?.close().catch(() => {}),\n\t\t\tthis.context?.close().catch(() => {}),\n\t\t\tthis.browser?.close().catch(() => {}),\n\t\t].filter(Boolean) as Promise<void>[]\n\t\tawait Promise.all(closePromises)\n\t\tthis.logger.debug('Browser closed', { stages: this.stageHistory.length })\n\t}\n\tasync getPage(): Promise<Page | null> {\n\t\treturn this.page\n\t}\n\tgetDebugDir(): string | null {\n\t\treturn this.debugDir\n\t}\n\tgetStageHistory(): ReadonlyArray<{ stage: string; ts: number }> {\n\t\treturn [...this.stageHistory]\n\t}\n}\n","import { createWriteStream, type WriteStream } from 'fs'\nimport { safeStringify } from './helpers.js'\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error'\nexport interface LoggerOptions {\n\tdebugMode?: boolean\n\tcorrelationId?: string\n\tlogFile?: string\n\tprefix?: string\n}\nexport class Logger {\n\tprivate minLevel: LogLevel\n\tprivate correlationId: string | undefined\n\tprivate fileStream: WriteStream | null = null\n\tprivate prefix: string\n\tconstructor(options: LoggerOptions = {}) {\n\t\tthis.minLevel = options.debugMode ? 'debug' : 'info'\n\t\tthis.correlationId = options.correlationId\n\t\tthis.prefix = options.prefix || ''\n\t\tif (options.logFile) {\n\t\t\tthis.fileStream = createWriteStream(options.logFile, { flags: 'a' })\n\t\t}\n\t}\n\tsetCorrelationId(id: string): void {\n\t\tthis.correlationId = id\n\t}\n\tsetDebug(enabled: boolean): void {\n\t\tthis.minLevel = enabled ? 'debug' : 'info'\n\t}\n\tprivate levelPriority(level: LogLevel): number {\n\t\treturn { debug: 0, info: 1, warn: 2, error: 3 }[level]\n\t}\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn this.levelPriority(level) >= this.levelPriority(this.minLevel)\n\t}\n\tprivate format(level: LogLevel, message: string, context?: unknown): string {\n\t\tconst ts = new Date().toISOString()\n\t\tconst corr = this.correlationId ? ` [${this.correlationId}]` : ''\n\t\tconst prefix = this.prefix ? ` [${this.prefix}]` : ''\n\t\tconst ctx = context ? ` | ${safeStringify(context)}` : ''\n\t\treturn `[${ts}]${corr}${prefix} ${level.toUpperCase()}: ${message}${ctx}`\n\t}\n\tprivate write(level: LogLevel, message: string, context?: unknown): void {\n\t\tif (!this.shouldLog(level)) return\n\t\tconst formatted = this.format(level, message, context)\n\t\tconst consoleMethod = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log'\n\t\tconsole[consoleMethod](formatted)\n\t\tif (this.fileStream?.writable) {\n\t\t\tthis.fileStream.write(formatted + '\\n')\n\t\t}\n\t}\n\tdebug(msg: string, ctx?: unknown): void {\n\t\tthis.write('debug', msg, ctx)\n\t}\n\tinfo(msg: string, ctx?: unknown): void {\n\t\tthis.write('info', msg, ctx)\n\t}\n\twarn(msg: string, ctx?: unknown): void {\n\t\tthis.write('warn', msg, ctx)\n\t}\n\terror(msg: string, ctx?: unknown, err?: Error): void {\n\t\tlet errorCtx: unknown\n\t\tif (err) {\n\t\t\tconst baseObj =\n\t\t\t\tctx && typeof ctx === 'object' && ctx !== null\n\t\t\t\t\t? { ...(ctx as Record<string, unknown>) }\n\t\t\t\t\t: {}\n\t\t\terrorCtx = {\n\t\t\t\t...baseObj,\n\t\t\t\terror: { name: err.name, message: err.message },\n\t\t\t}\n\t\t} else {\n\t\t\terrorCtx = ctx\n\t\t}\n\t\tthis.write('error', msg, errorCtx)\n\t}\n\tchild(prefix: string): Logger {\n\t\tconst childOptions: LoggerOptions = {\n\t\t\tdebugMode: this.minLevel === 'debug',\n\t\t\t...(this.correlationId !== undefined && { correlationId: this.correlationId }),\n\t\t\tprefix: this.prefix ? `${this.prefix}:${prefix}` : prefix,\n\t\t}\n\t\tconst child = new Logger(childOptions)\n\t\tif (this.fileStream) {\n\t\t\t;(child as any).fileStream = this.fileStream\n\t\t}\n\t\treturn child\n\t}\n\tasync close(): Promise<void> {\n\t\tif (this.fileStream && !this.fileStream.closed) {\n\t\t\treturn new Promise((resolve) => this.fileStream?.end(resolve))\n\t\t}\n\t}\n}\n","import { DEFAULTS } from './defaults.js'\nexport interface DownloadOptions {\n\theadless?: boolean\n\tuserAgent?: string\n\ttimeout?: number\n\tdownloadButtonTimeout?: number\n\tretries?: number\n\tretryDelay?: number\n\tonProgress?: (\n\t\tpercent: number,\n\t\ttotal: 100,\n\t\tmeta: { stage: string; message: string; attempt?: number },\n\t) => void\n\tcorrelationId?: string\n\tdebug?: boolean\n\tsaveDebugArtifacts?: boolean\n\tlogFile?: string\n\t_internal?: {\n\t\tstage?: string\n\t}\n}\nexport interface DownloadResult {\n\tfilePath: string\n\tsize: number\n\tmethod: 'direct' | 'fallback'\n\tcorrelationId?: string\n\tdurationMs?: number\n\tattempts?: number\n}\ntype NormalizedOptions = Required<\n\tOmit<DownloadOptions, 'onProgress' | 'correlationId' | '_internal' | 'logFile'>\n> & {\n\tonProgress?: DownloadOptions['onProgress']\n\tcorrelationId?: string\n\t_internal?: DownloadOptions['_internal']\n\tlogFile?: string\n}\nexport function normalizeOptions(opts?: DownloadOptions): NormalizedOptions {\n\tconst base = {\n\t\theadless: opts?.headless ?? DEFAULTS.headless,\n\t\tuserAgent: opts?.userAgent ?? DEFAULTS.userAgent,\n\t\ttimeout: opts?.timeout ?? DEFAULTS.timeout,\n\t\tdownloadButtonTimeout: opts?.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout,\n\t\tretries: opts?.retries ?? DEFAULTS.retries,\n\t\tretryDelay: opts?.retryDelay ?? DEFAULTS.retryDelay,\n\t\tdebug: opts?.debug ?? false,\n\t\tsaveDebugArtifacts: opts?.saveDebugArtifacts ?? DEFAULTS.saveDebugArtifacts,\n\t}\n\tconst optional = {\n\t\t...(opts?.onProgress !== undefined && { onProgress: opts.onProgress }),\n\t\t...(opts?.correlationId !== undefined && { correlationId: opts.correlationId }),\n\t\t...(opts?._internal !== undefined && { _internal: opts._internal }),\n\t\t...(opts?.logFile !== undefined && { logFile: opts.logFile }),\n\t}\n\treturn { ...base, ...optional } as NormalizedOptions\n}\n","import { ValidationError } from '../errors/index.js'\nimport { sanitizeFilename } from '../utils/helpers.js'\nimport { DEFAULTS } from '../config/defaults.js'\nexport class InputValidator {\n\tstatic validateUrl(\n\t\turl: unknown,\n\t\tallowedDomains: readonly string[] = ['sfile.co', 'sfile.mobi'],\n\t): asserts url is string {\n\t\tif (!url || typeof url !== 'string') {\n\t\t\tthrow new ValidationError('URL must be a non-empty string', {\n\t\t\t\treceived: typeof url,\n\t\t\t\turl,\n\t\t\t})\n\t\t}\n\t\tconst hasAllowedDomain = allowedDomains.some((domain) => url.includes(domain))\n\t\tif (!hasAllowedDomain) {\n\t\t\tthrow new ValidationError(`URL must contain one of: ${allowedDomains.join(', ')}`, {\n\t\t\t\turl,\n\t\t\t\tallowedDomains,\n\t\t\t})\n\t\t}\n\t\ttry {\n\t\t\tconst parsed = new URL(url)\n\t\t\tif (!['http:', 'https:'].includes(parsed.protocol)) {\n\t\t\t\tthrow new ValidationError('URL must use http or https protocol', {\n\t\t\t\t\turl,\n\t\t\t\t\tprotocol: parsed.protocol,\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (parseErr) {\n\t\t\tthrow new ValidationError('Invalid URL format', {\n\t\t\t\turl,\n\t\t\t\tparseError: parseErr instanceof Error ? parseErr.message : String(parseErr),\n\t\t\t})\n\t\t}\n\t}\n\tstatic validateSaveDir(dir: unknown): asserts dir is string {\n\t\tif (!dir || typeof dir !== 'string') {\n\t\t\tthrow new ValidationError('Save directory must be a non-empty string', {\n\t\t\t\treceived: typeof dir,\n\t\t\t\tdir,\n\t\t\t})\n\t\t}\n\t}\n\tstatic sanitizeFilename(name: string): string {\n\t\tconst replacement = DEFAULTS.sanitizeReplacement\n\t\tconst maxLength = DEFAULTS.maxFilenameLength\n\t\tconst sanitized = sanitizeFilename(name, replacement)\n\t\tif (!sanitized || sanitized.length === 0) {\n\t\t\tconst ext = name.includes('.') ? name.split('.').pop() : 'bin'\n\t\t\treturn `downloaded_file${ext ? '.' + ext : ''}`.slice(0, maxLength)\n\t\t}\n\t\treturn sanitized.slice(0, maxLength)\n\t}\n\tstatic validateOptions(options: unknown): void {\n\t\tif (options === undefined || options === null) {\n\t\t\treturn\n\t\t}\n\t\tif (typeof options !== 'object') {\n\t\t\tthrow new ValidationError('Options must be an object or undefined', {\n\t\t\t\treceived: typeof options,\n\t\t\t})\n\t\t}\n\t\tconst opts = options as Record<string, unknown>\n\t\tconst numericFields = ['timeout', 'retries', 'retryDelay', 'downloadButtonTimeout'] as const\n\t\tfor (const field of numericFields) {\n\t\t\tif (field in opts && opts[field] !== undefined && typeof opts[field] !== 'number') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a number`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst booleanFields = ['headless', 'debug', 'saveDebugArtifacts'] as const\n\t\tfor (const field of booleanFields) {\n\t\t\tif (field in opts && opts[field] !== undefined && typeof opts[field] !== 'boolean') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a boolean`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst stringFields = ['correlationId', 'logFile', 'userAgent'] as const\n\t\tfor (const field of stringFields) {\n\t\t\tif (field in opts && opts[field] !== undefined && typeof opts[field] !== 'string') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a string`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\t'onProgress' in opts &&\n\t\t\topts['onProgress'] !== undefined &&\n\t\t\ttypeof opts['onProgress'] !== 'function'\n\t\t) {\n\t\t\tthrow new ValidationError(`Option 'onProgress' must be a function`, {\n\t\t\t\treceived: typeof opts['onProgress'],\n\t\t\t})\n\t\t}\n\t}\n}\n","import * as path from 'path'\nimport { promises as fs } from 'fs'\nimport { randomUUID } from 'crypto'\nimport { BrowserManager } from '../browser/browser-manager.js'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError, AppError } from '../errors/index.js'\nimport { DownloadOptions, DownloadResult, normalizeOptions } from '../config/schema.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { InputValidator } from './validator.js'\nimport { sleep, calculateRetryDelay } from '../utils/helpers.js'\nfunction stripUndefined<T extends Record<string, unknown>>(obj: T): T {\n\treturn Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as T\n}\nfunction safeProgress(\n\tonProgress: unknown,\n\tpercent: number,\n\ttotal: number,\n\tmeta: Record<string, unknown>,\n): void {\n\tif (typeof onProgress === 'function') {\n\t\ttry {\n\t\t\t;(onProgress as any)(percent, total, meta)\n\t\t} catch (err) {\n\t\t\tconsole.warn('Progress callback error:', err)\n\t\t}\n\t}\n}\nasync function executeDownload(\n\turl: string,\n\tsaveDir: string,\n\topts: ReturnType<typeof normalizeOptions>,\n\tlogger: Logger,\n): Promise<DownloadResult> {\n\tconst startTime = Date.now()\n\tconst browserMgr = new BrowserManager(logger.child('BrowserManager'), {\n\t\theadless: opts.headless,\n\t\tuserAgent: opts.userAgent,\n\t\ttimeout: opts.timeout,\n\t\tdebug: opts.debug,\n\t\tdownloadButtonTimeout: opts.downloadButtonTimeout,\n\t})\n\tlet finalPath: string\n\tlet fileSize: number\n\tlet method: 'direct' | 'fallback'\n\ttry {\n\t\tlogger.info('Starting download workflow', { url })\n\t\tsafeProgress(opts.onProgress, 10, 100, {\n\t\t\tstage: 'launch',\n\t\t\tmessage: 'Launching browser',\n\t\t\tattempt: 1,\n\t\t})\n\t\tawait browserMgr.launch()\n\t\tawait browserMgr.goto(url, 'networkidle')\n\t\tsafeProgress(opts.onProgress, 30, 100, { stage: 'navigation', message: 'Page loaded' })\n\t\tawait browserMgr.waitForDownloadButton()\n\t\tsafeProgress(opts.onProgress, 50, 100, {\n\t\t\tstage: 'button',\n\t\t\tmessage: 'Download button ready',\n\t\t})\n\t\tconst intermediateUrl = await browserMgr.getIntermediateUrl()\n\t\tconst autoUrl = intermediateUrl.includes('?')\n\t\t\t? `${intermediateUrl}&auto=1`\n\t\t\t: `${intermediateUrl}?auto=1`\n\t\tlogger.debug('Triggering download', { autoUrl })\n\t\tsafeProgress(opts.onProgress, 70, 100, { stage: 'trigger', message: 'Download triggered' })\n\t\tlet download = await browserMgr.startDownloadAndWait(autoUrl)\n\t\tif (download) {\n\t\t\tconst suggested = download.suggestedFilename() || 'file.bin'\n\t\t\tconst filename = InputValidator.sanitizeFilename(suggested)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait download.saveAs(finalPath)\n\t\t\tconst stat = await fs.stat(finalPath)\n\t\t\tfileSize = stat.size\n\t\t\tmethod = 'direct'\n\t\t\tlogger.info('Saved via direct download', { path: finalPath, size: fileSize })\n\t\t} else {\n\t\t\tlogger.warn('Direct download not captured, trying fallback')\n\t\t\tconst fallback = await browserMgr.fallbackCollectFileResponse()\n\t\t\tif (!fallback) {\n\t\t\t\tthrow new NetworkError('No download event and no file response found', {\n\t\t\t\t\turl,\n\t\t\t\t\tintermediateUrl,\n\t\t\t\t\tautoUrl,\n\t\t\t\t\tstage: 'fallbackFailed',\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst { buffer, filename: rawName } = fallback\n\t\t\tconst filename = InputValidator.sanitizeFilename(rawName)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait fs.writeFile(finalPath, buffer)\n\t\t\tfileSize = buffer.length\n\t\t\tmethod = 'fallback'\n\t\t\tlogger.info('Saved via fallback', { path: finalPath, size: fileSize })\n\t\t}\n\t\tsafeProgress(opts.onProgress, 100, 100, { stage: 'complete', message: 'Download finished' })\n\t\tconst result: DownloadResult = {\n\t\t\tfilePath: finalPath,\n\t\t\tsize: fileSize,\n\t\t\tmethod,\n\t\t\tdurationMs: Date.now() - startTime,\n\t\t\tattempts: 1,\n\t\t}\n\t\tif (opts.correlationId !== undefined) {\n\t\t\tresult.correlationId = opts.correlationId\n\t\t}\n\t\treturn result\n\t} catch (err: unknown) {\n\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\tconst appError =\n\t\t\terror instanceof AppError\n\t\t\t\t? error\n\t\t\t\t: new NetworkError(error.message, {\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tsaveDir,\n\t\t\t\t\t\tcorrelationId: opts.correlationId,\n\t\t\t\t\t\toriginalError: error.message,\n\t\t\t\t\t\terrorName: error.name,\n\t\t\t\t\t})\n\t\tif (opts.saveDebugArtifacts) {\n\t\t\tconst debugPath = await browserMgr.saveDebugArtifacts(appError.message)\n\t\t\tif (debugPath) {\n\t\t\t\t;(appError as any).debugPath = debugPath\n\t\t\t\tif (appError.context && typeof appError.context === 'object') {\n\t\t\t\t\t;(appError.context as any).debugPath = debugPath\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow appError\n\t} finally {\n\t\tawait browserMgr\n\t\t\t.close()\n\t\t\t.catch((e) => logger.error('Failed to close browser', { error: e.message }))\n\t\tawait logger.close().catch((e) => console.error('Failed to close logger', e))\n\t}\n}\nexport async function downloadSfile(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<DownloadResult> {\n\tconst opts = normalizeOptions(options)\n\tconst correlationId = opts.correlationId || randomUUID()\n\ttype LoggerConstructorParams = ConstructorParameters<typeof Logger>\n\ttype LoggerOptionsType = LoggerConstructorParams[0]\n\tconst loggerOptions: LoggerOptionsType = {\n\t\tdebugMode: opts.debug,\n\t\tcorrelationId,\n\t\tprefix: 'downloadSfile',\n\t}\n\tif (opts.logFile !== undefined) {\n\t\tloggerOptions.logFile = opts.logFile\n\t}\n\tconst logger = new Logger(loggerOptions)\n\tInputValidator.validateUrl(url)\n\tInputValidator.validateSaveDir(saveDir)\n\tInputValidator.validateOptions(options)\n\tawait fs.mkdir(saveDir, { recursive: true })\n\tlet lastError: Error | undefined\n\tlet attempt = 0\n\twhile (attempt < opts.retries) {\n\t\tattempt++\n\t\ttry {\n\t\t\tlogger.info(`Download attempt ${attempt}/${opts.retries}`, { url })\n\t\t\tconst result = await executeDownload(url, saveDir, opts, logger)\n\t\t\tlogger.info(`Download succeeded`, {\n\t\t\t\tduration: result.durationMs,\n\t\t\t\tattempts: attempt,\n\t\t\t\tmethod: result.method,\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattempts: attempt,\n\t\t\t\tcorrelationId,\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tlastError = err instanceof Error ? err : new Error(String(err))\n\t\t\tconst isRetryable = lastError instanceof AppError && lastError.retryable\n\t\t\tconst isLastAttempt = attempt >= opts.retries\n\t\t\tif (!isRetryable || isLastAttempt) {\n\t\t\t\tlogger.error(`Download failed permanently`, {\n\t\t\t\t\terror: lastError.message,\n\t\t\t\t\tattempt,\n\t\t\t\t\tretryable: isRetryable,\n\t\t\t\t\tlastAttempt: isLastAttempt,\n\t\t\t\t})\n\t\t\t\tthrow lastError\n\t\t\t}\n\t\t\tconst delay = calculateRetryDelay(attempt, opts.retryDelay, DEFAULTS.maxRetryDelay)\n\t\t\tlogger.warn(`Retrying download`, {\n\t\t\t\tattempt,\n\t\t\t\tmaxAttempts: opts.retries,\n\t\t\t\tdelayMs: Math.round(delay),\n\t\t\t\terror: lastError.message,\n\t\t\t})\n\t\t\tsafeProgress(opts.onProgress, 0, 100, {\n\t\t\t\tstage: 'retry',\n\t\t\t\tmessage: `Retry ${attempt}/${opts.retries}`,\n\t\t\t\tattempt,\n\t\t\t})\n\t\t\tawait sleep(delay)\n\t\t}\n\t}\n\tthrow lastError || new Error('Download failed after all retries')\n}\nexport async function downloadSfileSafe(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\ttry {\n\t\tconst result = await downloadSfile(url, saveDir, options)\n\t\treturn { success: true, value: result }\n\t} catch (error) {\n\t\treturn { success: false, error: error as Error }\n\t}\n}\nexport function createDownloader(defaultOptions?: DownloadOptions) {\n\tconst defaults = normalizeOptions(defaultOptions)\n\treturn {\n\t\tasync download(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<DownloadResult> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfile(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\tasync downloadSafe(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfileSafe(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\twithOptions(newDefaults: Partial<DownloadOptions>) {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...newDefaults })\n\t\t\treturn createDownloader(merged as DownloadOptions)\n\t\t},\n\t}\n}\n","export type Result<T, E = Error> = { success: true; value: T } | { success: false; error: E }\nexport function ok<T, E = never>(value: T): Result<T, E> {\n\treturn { success: true, value }\n}\nexport function err<E, T = never>(error: E): Result<T, E> {\n\treturn { success: false, error }\n}\nexport function isSuccess<T, E>(result: Result<T, E>): result is { success: true; value: T } {\n\treturn result.success === true\n}\nexport function isFailure<T, E>(result: Result<T, E>): result is { success: false; error: E } {\n\treturn result.success === false\n}\nexport function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {\n\tif (result.success) {\n\t\treturn { success: true, value: fn(result.value) }\n\t}\n\treturn result\n}\nexport function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F> {\n\tif (!result.success) {\n\t\treturn { success: false, error: fn(result.error) }\n\t}\n\treturn result\n}\nexport function getOrThrow<T, E>(result: Result<T, E>): T {\n\tif (result.success) return result.value\n\tthrow result.error\n}\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;QAC9D,CAAC;AACD,QAAA,MAAM,YAAY,CACjB,GAAW,EACX,OAAe,EACf,WAA6B,EAAA;AAE7B,YAAA,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;YAC9D,OAAO,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAyB,CAAC;QAClE,CAAC;AACD,QAAA,WAAW,CAAC,WAAqC,EAAA;AAChD,YAAA,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;AAC9D,YAAA,OAAO,gBAAgB,CAAC,MAAyB,CAAC;QACnD,CAAC;KACD;AACF;;ACzOM,SAAU,SAAS,CAAO,MAAoB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,KAAK,IAAI;AAC/B;AACM,SAAU,SAAS,CAAO,MAAoB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,KAAK,KAAK;AAChC;AAOM,SAAU,QAAQ,CAAU,MAAoB,EAAE,EAAmB,EAAA;AAC1E,IAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACpB,QAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;IACnD;AACA,IAAA,OAAO,MAAM;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/build/lib.mjs CHANGED
@@ -645,7 +645,10 @@ class InputValidator {
645
645
  return sanitized.slice(0, maxLength);
646
646
  }
647
647
  static validateOptions(options) {
648
- if (options && typeof options !== 'object') {
648
+ if (options === undefined || options === null) {
649
+ return;
650
+ }
651
+ if (typeof options !== 'object') {
649
652
  throw new ValidationError('Options must be an object or undefined', {
650
653
  received: typeof options,
651
654
  });
@@ -653,7 +656,7 @@ class InputValidator {
653
656
  const opts = options;
654
657
  const numericFields = ['timeout', 'retries', 'retryDelay', 'downloadButtonTimeout'];
655
658
  for (const field of numericFields) {
656
- if (field in opts && typeof opts[field] !== 'number') {
659
+ if (field in opts && opts[field] !== undefined && typeof opts[field] !== 'number') {
657
660
  throw new ValidationError(`Option '${field}' must be a number`, {
658
661
  field,
659
662
  received: typeof opts[field],
@@ -663,7 +666,7 @@ class InputValidator {
663
666
  }
664
667
  const booleanFields = ['headless', 'debug', 'saveDebugArtifacts'];
665
668
  for (const field of booleanFields) {
666
- if (field in opts && typeof opts[field] !== 'boolean') {
669
+ if (field in opts && opts[field] !== undefined && typeof opts[field] !== 'boolean') {
667
670
  throw new ValidationError(`Option '${field}' must be a boolean`, {
668
671
  field,
669
672
  received: typeof opts[field],
@@ -671,6 +674,23 @@ class InputValidator {
671
674
  });
672
675
  }
673
676
  }
677
+ const stringFields = ['correlationId', 'logFile', 'userAgent'];
678
+ for (const field of stringFields) {
679
+ if (field in opts && opts[field] !== undefined && typeof opts[field] !== 'string') {
680
+ throw new ValidationError(`Option '${field}' must be a string`, {
681
+ field,
682
+ received: typeof opts[field],
683
+ value: opts[field],
684
+ });
685
+ }
686
+ }
687
+ if ('onProgress' in opts &&
688
+ opts['onProgress'] !== undefined &&
689
+ typeof opts['onProgress'] !== 'function') {
690
+ throw new ValidationError(`Option 'onProgress' must be a function`, {
691
+ received: typeof opts['onProgress'],
692
+ });
693
+ }
674
694
  }
675
695
  }
676
696
 
package/build/lib.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.mjs","sources":["../lib/errors/base.ts","../lib/errors/errors.ts","../lib/config/defaults.ts","../lib/browser/page-interactions.ts","../lib/utils/helpers.ts","../lib/browser/browser-manager.ts","../lib/utils/logger.ts","../lib/config/schema.ts","../lib/core/validator.ts","../lib/core/downloader.ts","../lib/utils/result.ts"],"sourcesContent":["export abstract class AppError extends Error {\n\tpublic readonly timestamp: string\n\tpublic readonly context: Readonly<Record<string, unknown>>\n\tpublic readonly code: string\n\tpublic readonly retryable: boolean\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: string,\n\t\tretryable: boolean = false,\n\t\tcontext?: Record<string, unknown>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = this.constructor.name\n\t\tthis.code = code\n\t\tthis.retryable = retryable\n\t\tthis.timestamp = new Date().toISOString()\n\t\tthis.context = context ? Object.freeze({ ...context }) : Object.freeze({})\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, this.constructor)\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\ttoJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tretryable: this.retryable,\n\t\t\ttimestamp: this.timestamp,\n\t\t\tcontext: this.context,\n\t\t\tstack: process.env['NODE_ENV'] === 'development' ? this.stack : undefined,\n\t\t}\n\t}\n\ttoString(): string {\n\t\treturn `${this.name} [${this.code}]: ${this.message}`\n\t}\n\tisCode(code: string): boolean {\n\t\treturn this.code === code\n\t}\n\tisRetryable(): boolean {\n\t\treturn this.retryable\n\t}\n}\n","import { AppError } from './base.js'\nexport class ValidationError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'VALIDATION_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class NetworkError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'NETWORK_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class FileError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'FILE_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class BrowserError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'BROWSER_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport function isAppError(err: unknown): err is AppError {\n\treturn err instanceof AppError\n}\nexport function isRetryableError(err: unknown): boolean {\n\treturn isAppError(err) && err.retryable\n}\nexport function isErrorWithCode(err: unknown, code: string): boolean {\n\treturn isAppError(err) && err.code === code\n}\n","export const DEFAULTS = {\n\tuserAgent:\n\t\t'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',\n\theadless: true,\n\ttimeout: 60000,\n\tdownloadButtonTimeout: 30000,\n\tfallbackWaitMs: 3000,\n\tretries: 3,\n\tretryDelay: 1000,\n\tmaxRetryDelay: 30000,\n\tsaveDebugArtifacts: true,\n\tmaxFilenameLength: 255,\n\tsanitizeReplacement: '_',\n} as const\nexport type Defaults = typeof DEFAULTS\n","import { Page } from 'playwright'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError } from '../errors/index.js'\nexport class SfilePageInteractions {\n\tconstructor(\n\t\tprivate page: Page,\n\t\tprivate logger: Logger,\n\t) {}\n\tasync waitForDownloadButton(timeout: number): Promise<void> {\n\t\tthis.logger.debug('Waiting for #download button', { timeout })\n\t\tconst button = this.page.locator('#download')\n\t\tawait button.waitFor({ state: 'visible', timeout })\n\t\tthis.logger.debug('Button is visible, checking if active')\n\t\tawait this.page.waitForFunction(\n\t\t\t() => {\n\t\t\t\tconst btn = document.querySelector('#download') as HTMLAnchorElement | null\n\t\t\t\tif (!btn) return false\n\t\t\t\tconst href = btn.getAttribute('href')\n\t\t\t\tconst style = window.getComputedStyle(btn)\n\t\t\t\tconst isDisabled =\n\t\t\t\t\tbtn.hasAttribute('disabled') ||\n\t\t\t\t\tbtn.getAttribute('aria-disabled') === 'true' ||\n\t\t\t\t\tbtn.classList.contains('disabled')\n\t\t\t\treturn !!(\n\t\t\t\t\thref &&\n\t\t\t\t\thref !== '#' &&\n\t\t\t\t\thref.trim() !== '' &&\n\t\t\t\t\tstyle.pointerEvents !== 'none' &&\n\t\t\t\t\t!isDisabled\n\t\t\t\t)\n\t\t\t},\n\t\t\t{ timeout },\n\t\t)\n\t\tthis.logger.debug('Download button is active and ready')\n\t}\n\tasync extractIntermediateUrl(): Promise<string> {\n\t\tthis.logger.debug('Extracting href from #download button')\n\t\ttry {\n\t\t\tconst href = await this.page.$eval('#download', (el) => {\n\t\t\t\tconst anchor = el as HTMLAnchorElement\n\t\t\t\treturn anchor.href\n\t\t\t})\n\t\t\tif (!href || href === '#' || href.trim() === '') {\n\t\t\t\tthrow new NetworkError('Download button href is empty or invalid', { href })\n\t\t\t}\n\t\t\treturn href\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof Error && err.message?.includes('Element not found')) {\n\t\t\t\tthrow new NetworkError('Download button (#download) not found in page', {\n\t\t\t\t\tselector: '#download',\n\t\t\t\t\toriginalError: err.message,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthrow err\n\t\t}\n\t}\n}\n","export function sanitizeFilename(name: string, replacement = '_'): string {\n\tconst safeName = name.replace(/\\.\\.[\\\\/]/g, '')\n\tconst sanitized = safeName\n\t\t.replace(/[<>:\"/\\\\|?*\\x00-\\x1F]/g, replacement)\n\t\t.replace(new RegExp(`${replacement}+`, 'g'), replacement)\n\t\t.trim()\n\tconst maxLength = 255\n\tconst trimmed = sanitized.slice(0, maxLength)\n\treturn trimmed || `file${replacement}bin`\n}\nexport const sleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms))\nexport function safeStringify(value: unknown, indent = 0): string {\n\ttry {\n\t\tconst seen = new WeakSet()\n\t\treturn JSON.stringify(\n\t\t\tvalue,\n\t\t\t(_key, val) => {\n\t\t\t\tif (typeof val === 'object' && val !== null) {\n\t\t\t\t\tif (seen.has(val)) return '[Circular]'\n\t\t\t\t\tseen.add(val)\n\t\t\t\t}\n\t\t\t\tif (typeof val === 'bigint') return val.toString() + 'n'\n\t\t\t\tif (val instanceof Error) {\n\t\t\t\t\treturn { name: val.name, message: val.message, stack: val.stack }\n\t\t\t\t}\n\t\t\t\treturn val\n\t\t\t},\n\t\t\tindent,\n\t\t)\n\t} catch {\n\t\treturn '[unserializable]'\n\t}\n}\nexport function extractFilenameFromContentDisposition(header: string | undefined): string | null {\n\tif (!header) return null\n\tconst encodedMatch = header.match(/filename\\*=UTF-8''([^;\\n\"]+)/i)\n\tif (encodedMatch?.[1]) {\n\t\ttry {\n\t\t\treturn decodeURIComponent(encodedMatch[1])\n\t\t} catch {}\n\t}\n\tconst quotedMatch = header.match(/filename\\s*=\\s*\"([^\"]+)\"/i)\n\tif (quotedMatch?.[1]) return quotedMatch[1]\n\tconst plainMatch = header.match(/filename\\s*=\\s*([^;,\\n\"]+)/i)\n\tif (plainMatch?.[1]) return plainMatch[1].trim()\n\treturn null\n}\nexport function calculateRetryDelay(\n\tattempt: number,\n\tbaseDelayMs: number,\n\tmaxDelayMs = 30000,\n): number {\n\tconst exponential = baseDelayMs * Math.pow(2, attempt - 1)\n\tconst jitter = Math.random() * 0.3 * exponential\n\treturn Math.min(exponential + jitter, maxDelayMs)\n}\nexport function isError(value: unknown): value is Error {\n\treturn (\n\t\tvalue instanceof Error ||\n\t\t(typeof value === 'object' && value !== null && 'message' in value)\n\t)\n}\n","import { chromium, Browser, BrowserContext, Page, Download, Response } from 'playwright'\nimport * as fs from 'fs/promises'\nimport path from 'path'\nimport os from 'os'\nimport { Logger } from '../utils/logger.js'\nimport { BrowserError, NetworkError } from '../errors/index.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { SfilePageInteractions } from './page-interactions.js'\nimport { sleep, extractFilenameFromContentDisposition } from '../utils/helpers.js'\nexport interface BrowserManagerOptions {\n\theadless: boolean\n\tuserAgent: string\n\ttimeout: number\n\tdebug: boolean\n\tdownloadButtonTimeout?: number\n}\nexport class BrowserManager {\n\tprivate browser: Browser | null = null\n\tprivate context: BrowserContext | null = null\n\tprivate page: Page | null = null\n\tprivate interactions: SfilePageInteractions | null = null\n\tprivate debugDir: string | null = null\n\tprivate readonly stageHistory: Array<{ stage: string; ts: number }> = []\n\tconstructor(\n\t\tprivate logger: Logger,\n\t\tprivate opts: BrowserManagerOptions,\n\t) {}\n\tprivate trackStage(stage: string): void {\n\t\tthis.stageHistory.push({ stage, ts: Date.now() })\n\t}\n\tasync launch(): Promise<void> {\n\t\tconst stage = 'launch'\n\t\tthis.trackStage(stage)\n\t\ttry {\n\t\t\tthis.logger.info('Launching browser', { headless: this.opts.headless })\n\t\t\tthis.browser = await chromium.launch({\n\t\t\t\theadless: this.opts.headless,\n\t\t\t\targs: [\n\t\t\t\t\t'--no-sandbox',\n\t\t\t\t\t'--disable-setuid-sandbox',\n\t\t\t\t\t'--disable-dev-shm-usage',\n\t\t\t\t\t'--disable-accelerated-2d-canvas',\n\t\t\t\t\t'--no-first-run',\n\t\t\t\t\t'--no-zygote',\n\t\t\t\t],\n\t\t\t})\n\t\t\tthis.context = await this.browser.newContext({\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t\tacceptDownloads: true,\n\t\t\t\tlocale: 'en-US',\n\t\t\t\ttimezoneId: 'UTC',\n\t\t\t\tviewport: { width: 1280, height: 720 },\n\t\t\t})\n\t\t\tawait this.context.addCookies([\n\t\t\t\t{\n\t\t\t\t\tname: 'safe_link_counter',\n\t\t\t\t\tvalue: '1',\n\t\t\t\t\tdomain: '.sfile.co',\n\t\t\t\t\tpath: '/',\n\t\t\t\t\texpires: Math.floor(Date.now() / 1000) + 3600,\n\t\t\t\t},\n\t\t\t])\n\t\t\tthis.page = await this.context.newPage()\n\t\t\tthis.interactions = new SfilePageInteractions(this.page, this.logger)\n\t\t\tif (this.opts.debug) {\n\t\t\t\tthis.setupDebugListeners()\n\t\t\t}\n\t\t\tthis.logger.info('Browser ready')\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new BrowserError(`Failed to launch browser: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t})\n\t\t}\n\t}\n\tprivate setupDebugListeners(): void {\n\t\tif (!this.page) return\n\t\tthis.page.on('console', (msg) => {\n\t\t\tconst type = msg.type()\n\t\t\tconst text = msg.text()\n\t\t\tif (type === 'error') {\n\t\t\t\tthis.logger.error(`[console] ${text}`, { location: msg.location() })\n\t\t\t} else if (type === 'warning') {\n\t\t\t\tthis.logger.warn(`[console] ${text}`)\n\t\t\t} else if (type === 'debug') {\n\t\t\t\tthis.logger.debug(`[console] ${text}`)\n\t\t\t}\n\t\t})\n\t\tthis.page.on('pageerror', (err) => {\n\t\t\tthis.logger.error('[pageerror]', undefined, err)\n\t\t})\n\t\tthis.page.on('requestfailed', (req) => {\n\t\t\tconst failure = req.failure()\n\t\t\tthis.logger.warn('[requestfailed]', {\n\t\t\t\turl: req.url(),\n\t\t\t\tmethod: req.method(),\n\t\t\t\terror: failure?.errorText,\n\t\t\t})\n\t\t})\n\t}\n\tasync goto(\n\t\turl: string,\n\t\twaitUntil: 'load' | 'networkidle' | 'commit' | 'domcontentloaded' = 'networkidle',\n\t): Promise<void> {\n\t\tconst stage = 'navigation'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\ttry {\n\t\t\tthis.logger.debug(`Navigating to ${url}`, { waitUntil, timeout: this.opts.timeout })\n\t\t\tawait this.page.goto(url, { waitUntil, timeout: this.opts.timeout })\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Navigation failed: ${err.message}`, {\n\t\t\t\turl,\n\t\t\t\tstage,\n\t\t\t\twaitUntil,\n\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync waitForDownloadButton(): Promise<void> {\n\t\tconst stage = 'waitForButton'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\tconst timeout = this.opts.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout\n\t\ttry {\n\t\t\tawait this.interactions.waitForDownloadButton(timeout)\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to wait for download button: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\ttimeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync getIntermediateUrl(): Promise<string> {\n\t\tconst stage = 'extractUrl'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\ttry {\n\t\t\tconst url = await this.interactions.extractIntermediateUrl()\n\t\t\tthis.logger.debug('Intermediate URL extracted', { url })\n\t\t\treturn url\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to extract intermediate URL: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync startDownloadAndWait(autoUrl: string): Promise<Download | null> {\n\t\tconst stage = 'downloadWait'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tconst downloadPromise = this.page\n\t\t\t.waitForEvent('download', { timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.debug('Download event timeout', {\n\t\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t\treturn null\n\t\t\t})\n\t\tthis.logger.debug('Navigating to auto download URL', { url: autoUrl })\n\t\tawait this.page\n\t\t\t.goto(autoUrl, { waitUntil: 'commit', timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.warn('Navigation to auto URL failed, continuing anyway', {\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t})\n\t\tconst download = await downloadPromise\n\t\tif (download) {\n\t\t\tthis.logger.info('Download event captured')\n\t\t\treturn download\n\t\t}\n\t\tthis.logger.debug('No download event captured within timeout')\n\t\treturn null\n\t}\n\tasync fallbackCollectFileResponse(): Promise<{ buffer: Buffer; filename: string } | null> {\n\t\tconst stage = 'fallbackIntercept'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tthis.logger.info('Falling back to response interception')\n\t\tconst responses: Response[] = []\n\t\tconst handler = (res: Response) => responses.push(res)\n\t\tthis.page.on('response', handler)\n\t\tawait sleep(DEFAULTS.fallbackWaitMs)\n\t\tthis.page.off('response', handler)\n\t\tconst fileResponse = [...responses].reverse().find((r) => {\n\t\t\tconst headers = r.headers()\n\t\t\tconst disposition = headers['content-disposition']\n\t\t\tconst contentType = headers['content-type']\n\t\t\tconst url = r.url()\n\t\t\treturn (\n\t\t\t\t(disposition && disposition.includes('attachment')) ||\n\t\t\t\turl.includes('/downloadfile/') ||\n\t\t\t\t(contentType &&\n\t\t\t\t\t!contentType.startsWith('text/html') &&\n\t\t\t\t\t!contentType.startsWith('application/json'))\n\t\t\t)\n\t\t})\n\t\tif (!fileResponse) {\n\t\t\tthis.logger.debug('No suitable file response found in fallback', {\n\t\t\t\tresponseCount: responses.length,\n\t\t\t\tsampleUrls: responses.slice(0, 3).map((r) => r.url()),\n\t\t\t})\n\t\t\treturn null\n\t\t}\n\t\ttry {\n\t\t\tconst buffer = await fileResponse.body()\n\t\t\tlet filename = extractFilenameFromContentDisposition(\n\t\t\t\tfileResponse.headers()['content-disposition'],\n\t\t\t)\n\t\t\tif (!filename) {\n\t\t\t\tconst urlParts = fileResponse.url().split('/')\n\t\t\t\tfilename = urlParts[urlParts.length - 1]?.split('?')[0] || 'file.bin'\n\t\t\t}\n\t\t\tfilename = filename.replace(/[<>:\"/\\\\|?*]/g, '_')\n\t\t\tthis.logger.info('Fallback response captured', {\n\t\t\t\tfilename,\n\t\t\t\tsize: buffer.length,\n\t\t\t\tcontentType: fileResponse.headers()['content-type'],\n\t\t\t})\n\t\t\treturn { buffer, filename }\n\t\t} catch (err: any) {\n\t\t\tthis.logger.error('Failed to read fallback response body', { error: err.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tasync saveDebugArtifacts(errorMessage: string): Promise<string | null> {\n\t\tif (!this.opts.debug || !this.page) return null\n\t\ttry {\n\t\t\tthis.debugDir = path.join(\n\t\t\t\tos.tmpdir(),\n\t\t\t\t`sfile_debug_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,\n\t\t\t)\n\t\t\tawait fs.mkdir(this.debugDir, { recursive: true })\n\t\t\tconst tasks: Promise<void>[] = [\n\t\t\t\tthis.page\n\t\t\t\t\t.screenshot({\n\t\t\t\t\t\tpath: path.join(this.debugDir, 'error.png'),\n\t\t\t\t\t\tfullPage: true,\n\t\t\t\t\t})\n\t\t\t\t\t.then(() => {}),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.html'), await this.page.content()),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.txt'), errorMessage),\n\t\t\t\tfs.writeFile(\n\t\t\t\t\tpath.join(this.debugDir, 'stages.json'),\n\t\t\t\t\tJSON.stringify(this.stageHistory, null, 2),\n\t\t\t\t),\n\t\t\t]\n\t\t\tawait Promise.all(tasks)\n\t\t\tthis.logger.info('Debug artifacts saved', { debugDir: this.debugDir })\n\t\t\treturn this.debugDir\n\t\t} catch (e: any) {\n\t\t\tthis.logger.error('Failed to save debug artifacts', { error: e.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tprivate async handleStageError(stage: string, error: any): Promise<void> {\n\t\tif (this.opts.debug) {\n\t\t\tawait this.saveDebugArtifacts(\n\t\t\t\t`Error at stage \"${stage}\": ${error?.message || 'Unknown error'}`,\n\t\t\t)\n\t\t}\n\t}\n\tasync close(): Promise<void> {\n\t\tconst closePromises = [\n\t\t\tthis.page?.close().catch(() => {}),\n\t\t\tthis.context?.close().catch(() => {}),\n\t\t\tthis.browser?.close().catch(() => {}),\n\t\t].filter(Boolean) as Promise<void>[]\n\t\tawait Promise.all(closePromises)\n\t\tthis.logger.debug('Browser closed', { stages: this.stageHistory.length })\n\t}\n\tasync getPage(): Promise<Page | null> {\n\t\treturn this.page\n\t}\n\tgetDebugDir(): string | null {\n\t\treturn this.debugDir\n\t}\n\tgetStageHistory(): ReadonlyArray<{ stage: string; ts: number }> {\n\t\treturn [...this.stageHistory]\n\t}\n}\n","import { createWriteStream, type WriteStream } from 'fs'\nimport { safeStringify } from './helpers.js'\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error'\nexport interface LoggerOptions {\n\tdebugMode?: boolean\n\tcorrelationId?: string\n\tlogFile?: string\n\tprefix?: string\n}\nexport class Logger {\n\tprivate minLevel: LogLevel\n\tprivate correlationId: string | undefined\n\tprivate fileStream: WriteStream | null = null\n\tprivate prefix: string\n\tconstructor(options: LoggerOptions = {}) {\n\t\tthis.minLevel = options.debugMode ? 'debug' : 'info'\n\t\tthis.correlationId = options.correlationId\n\t\tthis.prefix = options.prefix || ''\n\t\tif (options.logFile) {\n\t\t\tthis.fileStream = createWriteStream(options.logFile, { flags: 'a' })\n\t\t}\n\t}\n\tsetCorrelationId(id: string): void {\n\t\tthis.correlationId = id\n\t}\n\tsetDebug(enabled: boolean): void {\n\t\tthis.minLevel = enabled ? 'debug' : 'info'\n\t}\n\tprivate levelPriority(level: LogLevel): number {\n\t\treturn { debug: 0, info: 1, warn: 2, error: 3 }[level]\n\t}\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn this.levelPriority(level) >= this.levelPriority(this.minLevel)\n\t}\n\tprivate format(level: LogLevel, message: string, context?: unknown): string {\n\t\tconst ts = new Date().toISOString()\n\t\tconst corr = this.correlationId ? ` [${this.correlationId}]` : ''\n\t\tconst prefix = this.prefix ? ` [${this.prefix}]` : ''\n\t\tconst ctx = context ? ` | ${safeStringify(context)}` : ''\n\t\treturn `[${ts}]${corr}${prefix} ${level.toUpperCase()}: ${message}${ctx}`\n\t}\n\tprivate write(level: LogLevel, message: string, context?: unknown): void {\n\t\tif (!this.shouldLog(level)) return\n\t\tconst formatted = this.format(level, message, context)\n\t\tconst consoleMethod = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log'\n\t\tconsole[consoleMethod](formatted)\n\t\tif (this.fileStream?.writable) {\n\t\t\tthis.fileStream.write(formatted + '\\n')\n\t\t}\n\t}\n\tdebug(msg: string, ctx?: unknown): void {\n\t\tthis.write('debug', msg, ctx)\n\t}\n\tinfo(msg: string, ctx?: unknown): void {\n\t\tthis.write('info', msg, ctx)\n\t}\n\twarn(msg: string, ctx?: unknown): void {\n\t\tthis.write('warn', msg, ctx)\n\t}\n\terror(msg: string, ctx?: unknown, err?: Error): void {\n\t\tlet errorCtx: unknown\n\t\tif (err) {\n\t\t\tconst baseObj =\n\t\t\t\tctx && typeof ctx === 'object' && ctx !== null\n\t\t\t\t\t? { ...(ctx as Record<string, unknown>) }\n\t\t\t\t\t: {}\n\t\t\terrorCtx = {\n\t\t\t\t...baseObj,\n\t\t\t\terror: { name: err.name, message: err.message },\n\t\t\t}\n\t\t} else {\n\t\t\terrorCtx = ctx\n\t\t}\n\t\tthis.write('error', msg, errorCtx)\n\t}\n\tchild(prefix: string): Logger {\n\t\tconst childOptions: LoggerOptions = {\n\t\t\tdebugMode: this.minLevel === 'debug',\n\t\t\t...(this.correlationId !== undefined && { correlationId: this.correlationId }),\n\t\t\tprefix: this.prefix ? `${this.prefix}:${prefix}` : prefix,\n\t\t}\n\t\tconst child = new Logger(childOptions)\n\t\tif (this.fileStream) {\n\t\t\t;(child as any).fileStream = this.fileStream\n\t\t}\n\t\treturn child\n\t}\n\tasync close(): Promise<void> {\n\t\tif (this.fileStream && !this.fileStream.closed) {\n\t\t\treturn new Promise((resolve) => this.fileStream?.end(resolve))\n\t\t}\n\t}\n}\n","import { DEFAULTS } from './defaults.js'\nexport interface DownloadOptions {\n\theadless?: boolean\n\tuserAgent?: string\n\ttimeout?: number\n\tdownloadButtonTimeout?: number\n\tretries?: number\n\tretryDelay?: number\n\tonProgress?: (\n\t\tpercent: number,\n\t\ttotal: 100,\n\t\tmeta: { stage: string; message: string; attempt?: number },\n\t) => void\n\tcorrelationId?: string\n\tdebug?: boolean\n\tsaveDebugArtifacts?: boolean\n\tlogFile?: string\n\t_internal?: {\n\t\tstage?: string\n\t}\n}\nexport interface DownloadResult {\n\tfilePath: string\n\tsize: number\n\tmethod: 'direct' | 'fallback'\n\tcorrelationId?: string\n\tdurationMs?: number\n\tattempts?: number\n}\ntype NormalizedOptions = Required<\n\tOmit<DownloadOptions, 'onProgress' | 'correlationId' | '_internal' | 'logFile'>\n> & {\n\tonProgress?: DownloadOptions['onProgress']\n\tcorrelationId?: string\n\t_internal?: DownloadOptions['_internal']\n\tlogFile?: string\n}\nexport function normalizeOptions(opts?: DownloadOptions): NormalizedOptions {\n\tconst base = {\n\t\theadless: opts?.headless ?? DEFAULTS.headless,\n\t\tuserAgent: opts?.userAgent ?? DEFAULTS.userAgent,\n\t\ttimeout: opts?.timeout ?? DEFAULTS.timeout,\n\t\tdownloadButtonTimeout: opts?.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout,\n\t\tretries: opts?.retries ?? DEFAULTS.retries,\n\t\tretryDelay: opts?.retryDelay ?? DEFAULTS.retryDelay,\n\t\tdebug: opts?.debug ?? false,\n\t\tsaveDebugArtifacts: opts?.saveDebugArtifacts ?? DEFAULTS.saveDebugArtifacts,\n\t}\n\tconst optional = {\n\t\t...(opts?.onProgress !== undefined && { onProgress: opts.onProgress }),\n\t\t...(opts?.correlationId !== undefined && { correlationId: opts.correlationId }),\n\t\t...(opts?._internal !== undefined && { _internal: opts._internal }),\n\t\t...(opts?.logFile !== undefined && { logFile: opts.logFile }),\n\t}\n\treturn { ...base, ...optional } as NormalizedOptions\n}\n","import { ValidationError } from '../errors/index.js'\nimport { sanitizeFilename } from '../utils/helpers.js'\nimport { DEFAULTS } from '../config/defaults.js'\nexport class InputValidator {\n\tstatic validateUrl(\n\t\turl: unknown,\n\t\tallowedDomains: readonly string[] = ['sfile.co', 'sfile.mobi'],\n\t): asserts url is string {\n\t\tif (!url || typeof url !== 'string') {\n\t\t\tthrow new ValidationError('URL must be a non-empty string', {\n\t\t\t\treceived: typeof url,\n\t\t\t\turl,\n\t\t\t})\n\t\t}\n\t\tconst hasAllowedDomain = allowedDomains.some((domain) => url.includes(domain))\n\t\tif (!hasAllowedDomain) {\n\t\t\tthrow new ValidationError(`URL must contain one of: ${allowedDomains.join(', ')}`, {\n\t\t\t\turl,\n\t\t\t\tallowedDomains,\n\t\t\t})\n\t\t}\n\t\ttry {\n\t\t\tconst parsed = new URL(url)\n\t\t\tif (!['http:', 'https:'].includes(parsed.protocol)) {\n\t\t\t\tthrow new ValidationError('URL must use http or https protocol', {\n\t\t\t\t\turl,\n\t\t\t\t\tprotocol: parsed.protocol,\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (parseErr) {\n\t\t\tthrow new ValidationError('Invalid URL format', {\n\t\t\t\turl,\n\t\t\t\tparseError: parseErr instanceof Error ? parseErr.message : String(parseErr),\n\t\t\t})\n\t\t}\n\t}\n\tstatic validateSaveDir(dir: unknown): asserts dir is string {\n\t\tif (!dir || typeof dir !== 'string') {\n\t\t\tthrow new ValidationError('Save directory must be a non-empty string', {\n\t\t\t\treceived: typeof dir,\n\t\t\t\tdir,\n\t\t\t})\n\t\t}\n\t}\n\tstatic sanitizeFilename(name: string): string {\n\t\tconst replacement = DEFAULTS.sanitizeReplacement\n\t\tconst maxLength = DEFAULTS.maxFilenameLength\n\t\tconst sanitized = sanitizeFilename(name, replacement)\n\t\tif (!sanitized || sanitized.length === 0) {\n\t\t\tconst ext = name.includes('.') ? name.split('.').pop() : 'bin'\n\t\t\treturn `downloaded_file${ext ? '.' + ext : ''}`.slice(0, maxLength)\n\t\t}\n\t\treturn sanitized.slice(0, maxLength)\n\t}\n\tstatic validateOptions(options: unknown): void {\n\t\tif (options && typeof options !== 'object') {\n\t\t\tthrow new ValidationError('Options must be an object or undefined', {\n\t\t\t\treceived: typeof options,\n\t\t\t})\n\t\t}\n\t\tconst opts = options as Record<string, unknown>\n\t\tconst numericFields = ['timeout', 'retries', 'retryDelay', 'downloadButtonTimeout'] as const\n\t\tfor (const field of numericFields) {\n\t\t\tif (field in opts && typeof opts[field] !== 'number') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a number`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst booleanFields = ['headless', 'debug', 'saveDebugArtifacts'] as const\n\t\tfor (const field of booleanFields) {\n\t\t\tif (field in opts && typeof opts[field] !== 'boolean') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a boolean`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n","import * as path from 'path'\nimport { promises as fs } from 'fs'\nimport { randomUUID } from 'crypto'\nimport { BrowserManager } from '../browser/browser-manager.js'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError, AppError } from '../errors/index.js'\nimport { DownloadOptions, DownloadResult, normalizeOptions } from '../config/schema.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { InputValidator } from './validator.js'\nimport { sleep, calculateRetryDelay } from '../utils/helpers.js'\nfunction stripUndefined<T extends Record<string, unknown>>(obj: T): T {\n\treturn Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as T\n}\nfunction safeProgress(\n\tonProgress: unknown,\n\tpercent: number,\n\ttotal: number,\n\tmeta: Record<string, unknown>,\n): void {\n\tif (typeof onProgress === 'function') {\n\t\ttry {\n\t\t\t;(onProgress as any)(percent, total, meta)\n\t\t} catch (err) {\n\t\t\tconsole.warn('Progress callback error:', err)\n\t\t}\n\t}\n}\nasync function executeDownload(\n\turl: string,\n\tsaveDir: string,\n\topts: ReturnType<typeof normalizeOptions>,\n\tlogger: Logger,\n): Promise<DownloadResult> {\n\tconst startTime = Date.now()\n\tconst browserMgr = new BrowserManager(logger.child('BrowserManager'), {\n\t\theadless: opts.headless,\n\t\tuserAgent: opts.userAgent,\n\t\ttimeout: opts.timeout,\n\t\tdebug: opts.debug,\n\t\tdownloadButtonTimeout: opts.downloadButtonTimeout,\n\t})\n\tlet finalPath: string\n\tlet fileSize: number\n\tlet method: 'direct' | 'fallback'\n\ttry {\n\t\tlogger.info('Starting download workflow', { url })\n\t\tsafeProgress(opts.onProgress, 10, 100, {\n\t\t\tstage: 'launch',\n\t\t\tmessage: 'Launching browser',\n\t\t\tattempt: 1,\n\t\t})\n\t\tawait browserMgr.launch()\n\t\tawait browserMgr.goto(url, 'networkidle')\n\t\tsafeProgress(opts.onProgress, 30, 100, { stage: 'navigation', message: 'Page loaded' })\n\t\tawait browserMgr.waitForDownloadButton()\n\t\tsafeProgress(opts.onProgress, 50, 100, {\n\t\t\tstage: 'button',\n\t\t\tmessage: 'Download button ready',\n\t\t})\n\t\tconst intermediateUrl = await browserMgr.getIntermediateUrl()\n\t\tconst autoUrl = intermediateUrl.includes('?')\n\t\t\t? `${intermediateUrl}&auto=1`\n\t\t\t: `${intermediateUrl}?auto=1`\n\t\tlogger.debug('Triggering download', { autoUrl })\n\t\tsafeProgress(opts.onProgress, 70, 100, { stage: 'trigger', message: 'Download triggered' })\n\t\tlet download = await browserMgr.startDownloadAndWait(autoUrl)\n\t\tif (download) {\n\t\t\tconst suggested = download.suggestedFilename() || 'file.bin'\n\t\t\tconst filename = InputValidator.sanitizeFilename(suggested)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait download.saveAs(finalPath)\n\t\t\tconst stat = await fs.stat(finalPath)\n\t\t\tfileSize = stat.size\n\t\t\tmethod = 'direct'\n\t\t\tlogger.info('Saved via direct download', { path: finalPath, size: fileSize })\n\t\t} else {\n\t\t\tlogger.warn('Direct download not captured, trying fallback')\n\t\t\tconst fallback = await browserMgr.fallbackCollectFileResponse()\n\t\t\tif (!fallback) {\n\t\t\t\tthrow new NetworkError('No download event and no file response found', {\n\t\t\t\t\turl,\n\t\t\t\t\tintermediateUrl,\n\t\t\t\t\tautoUrl,\n\t\t\t\t\tstage: 'fallbackFailed',\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst { buffer, filename: rawName } = fallback\n\t\t\tconst filename = InputValidator.sanitizeFilename(rawName)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait fs.writeFile(finalPath, buffer)\n\t\t\tfileSize = buffer.length\n\t\t\tmethod = 'fallback'\n\t\t\tlogger.info('Saved via fallback', { path: finalPath, size: fileSize })\n\t\t}\n\t\tsafeProgress(opts.onProgress, 100, 100, { stage: 'complete', message: 'Download finished' })\n\t\tconst result: DownloadResult = {\n\t\t\tfilePath: finalPath,\n\t\t\tsize: fileSize,\n\t\t\tmethod,\n\t\t\tdurationMs: Date.now() - startTime,\n\t\t\tattempts: 1,\n\t\t}\n\t\tif (opts.correlationId !== undefined) {\n\t\t\tresult.correlationId = opts.correlationId\n\t\t}\n\t\treturn result\n\t} catch (err: unknown) {\n\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\tconst appError =\n\t\t\terror instanceof AppError\n\t\t\t\t? error\n\t\t\t\t: new NetworkError(error.message, {\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tsaveDir,\n\t\t\t\t\t\tcorrelationId: opts.correlationId,\n\t\t\t\t\t\toriginalError: error.message,\n\t\t\t\t\t\terrorName: error.name,\n\t\t\t\t\t})\n\t\tif (opts.saveDebugArtifacts) {\n\t\t\tconst debugPath = await browserMgr.saveDebugArtifacts(appError.message)\n\t\t\tif (debugPath) {\n\t\t\t\t;(appError as any).debugPath = debugPath\n\t\t\t\tif (appError.context && typeof appError.context === 'object') {\n\t\t\t\t\t;(appError.context as any).debugPath = debugPath\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow appError\n\t} finally {\n\t\tawait browserMgr\n\t\t\t.close()\n\t\t\t.catch((e) => logger.error('Failed to close browser', { error: e.message }))\n\t\tawait logger.close().catch((e) => console.error('Failed to close logger', e))\n\t}\n}\nexport async function downloadSfile(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<DownloadResult> {\n\tconst opts = normalizeOptions(options)\n\tconst correlationId = opts.correlationId || randomUUID()\n\ttype LoggerConstructorParams = ConstructorParameters<typeof Logger>\n\ttype LoggerOptionsType = LoggerConstructorParams[0]\n\tconst loggerOptions: LoggerOptionsType = {\n\t\tdebugMode: opts.debug,\n\t\tcorrelationId,\n\t\tprefix: 'downloadSfile',\n\t}\n\tif (opts.logFile !== undefined) {\n\t\tloggerOptions.logFile = opts.logFile\n\t}\n\tconst logger = new Logger(loggerOptions)\n\tInputValidator.validateUrl(url)\n\tInputValidator.validateSaveDir(saveDir)\n\tInputValidator.validateOptions(options)\n\tawait fs.mkdir(saveDir, { recursive: true })\n\tlet lastError: Error | undefined\n\tlet attempt = 0\n\twhile (attempt < opts.retries) {\n\t\tattempt++\n\t\ttry {\n\t\t\tlogger.info(`Download attempt ${attempt}/${opts.retries}`, { url })\n\t\t\tconst result = await executeDownload(url, saveDir, opts, logger)\n\t\t\tlogger.info(`Download succeeded`, {\n\t\t\t\tduration: result.durationMs,\n\t\t\t\tattempts: attempt,\n\t\t\t\tmethod: result.method,\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattempts: attempt,\n\t\t\t\tcorrelationId,\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tlastError = err instanceof Error ? err : new Error(String(err))\n\t\t\tconst isRetryable = lastError instanceof AppError && lastError.retryable\n\t\t\tconst isLastAttempt = attempt >= opts.retries\n\t\t\tif (!isRetryable || isLastAttempt) {\n\t\t\t\tlogger.error(`Download failed permanently`, {\n\t\t\t\t\terror: lastError.message,\n\t\t\t\t\tattempt,\n\t\t\t\t\tretryable: isRetryable,\n\t\t\t\t\tlastAttempt: isLastAttempt,\n\t\t\t\t})\n\t\t\t\tthrow lastError\n\t\t\t}\n\t\t\tconst delay = calculateRetryDelay(attempt, opts.retryDelay, DEFAULTS.maxRetryDelay)\n\t\t\tlogger.warn(`Retrying download`, {\n\t\t\t\tattempt,\n\t\t\t\tmaxAttempts: opts.retries,\n\t\t\t\tdelayMs: Math.round(delay),\n\t\t\t\terror: lastError.message,\n\t\t\t})\n\t\t\tsafeProgress(opts.onProgress, 0, 100, {\n\t\t\t\tstage: 'retry',\n\t\t\t\tmessage: `Retry ${attempt}/${opts.retries}`,\n\t\t\t\tattempt,\n\t\t\t})\n\t\t\tawait sleep(delay)\n\t\t}\n\t}\n\tthrow lastError || new Error('Download failed after all retries')\n}\nexport async function downloadSfileSafe(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\ttry {\n\t\tconst result = await downloadSfile(url, saveDir, options)\n\t\treturn { success: true, value: result }\n\t} catch (error) {\n\t\treturn { success: false, error: error as Error }\n\t}\n}\nexport function createDownloader(defaultOptions?: DownloadOptions) {\n\tconst defaults = normalizeOptions(defaultOptions)\n\treturn {\n\t\tasync download(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<DownloadResult> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfile(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\tasync downloadSafe(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfileSafe(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\twithOptions(newDefaults: Partial<DownloadOptions>) {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...newDefaults })\n\t\t\treturn createDownloader(merged as DownloadOptions)\n\t\t},\n\t}\n}\n","export type Result<T, E = Error> = { success: true; value: T } | { success: false; error: E }\nexport function ok<T, E = never>(value: T): Result<T, E> {\n\treturn { success: true, value }\n}\nexport function err<E, T = never>(error: E): Result<T, E> {\n\treturn { success: false, error }\n}\nexport function isSuccess<T, E>(result: Result<T, E>): result is { success: true; value: T } {\n\treturn result.success === true\n}\nexport function isFailure<T, E>(result: Result<T, E>): result is { success: false; error: E } {\n\treturn result.success === false\n}\nexport function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {\n\tif (result.success) {\n\t\treturn { success: true, value: fn(result.value) }\n\t}\n\treturn result\n}\nexport function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F> {\n\tif (!result.success) {\n\t\treturn { success: false, error: fn(result.error) }\n\t}\n\treturn result\n}\nexport function getOrThrow<T, E>(result: Result<T, E>): T {\n\tif (result.success) return result.value\n\tthrow result.error\n}\n"],"names":["path","fs"],"mappings":";;;;;;;;AAAM,MAAgB,QAAS,SAAQ,KAAK,CAAA;AAC3B,IAAA,SAAS;AACT,IAAA,OAAO;AACP,IAAA,IAAI;AACJ,IAAA,SAAS;AACzB,IAAA,WAAA,CACC,OAAe,EACf,IAAY,EACZ,SAAA,GAAqB,KAAK,EAC1B,OAAiC,EAAA;QAEjC,KAAK,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;AACjC,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1E,QAAA,IAAI,KAAK,CAAC,iBAAiB,EAAE;YAC5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AO,gBAAgB,CAAC,MAAyB,CAAC;QACnD,CAAC;KACD;AACF;;ACzOM,SAAU,SAAS,CAAO,MAAoB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,KAAK,IAAI;AAC/B;AACM,SAAU,SAAS,CAAO,MAAoB,EAAA;AACnD,IAAA,OAAO,MAAM,CAAC,OAAO,KAAK,KAAK;AAChC;AAOM,SAAU,QAAQ,CAAU,MAAoB,EAAE,EAAmB,EAAA;AAC1E,IAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACpB,QAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;IACnD;AACA,IAAA,OAAO,MAAM;AACd;;;;"}
1
+ {"version":3,"file":"lib.mjs","sources":["../lib/errors/base.ts","../lib/errors/errors.ts","../lib/config/defaults.ts","../lib/browser/page-interactions.ts","../lib/utils/helpers.ts","../lib/browser/browser-manager.ts","../lib/utils/logger.ts","../lib/config/schema.ts","../lib/core/validator.ts","../lib/core/downloader.ts","../lib/utils/result.ts"],"sourcesContent":["export abstract class AppError extends Error {\n\tpublic readonly timestamp: string\n\tpublic readonly context: Readonly<Record<string, unknown>>\n\tpublic readonly code: string\n\tpublic readonly retryable: boolean\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: string,\n\t\tretryable: boolean = false,\n\t\tcontext?: Record<string, unknown>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = this.constructor.name\n\t\tthis.code = code\n\t\tthis.retryable = retryable\n\t\tthis.timestamp = new Date().toISOString()\n\t\tthis.context = context ? Object.freeze({ ...context }) : Object.freeze({})\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, this.constructor)\n\t\t}\n\t\tObject.freeze(this)\n\t}\n\ttoJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tretryable: this.retryable,\n\t\t\ttimestamp: this.timestamp,\n\t\t\tcontext: this.context,\n\t\t\tstack: process.env['NODE_ENV'] === 'development' ? this.stack : undefined,\n\t\t}\n\t}\n\ttoString(): string {\n\t\treturn `${this.name} [${this.code}]: ${this.message}`\n\t}\n\tisCode(code: string): boolean {\n\t\treturn this.code === code\n\t}\n\tisRetryable(): boolean {\n\t\treturn this.retryable\n\t}\n}\n","import { AppError } from './base.js'\nexport class ValidationError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'VALIDATION_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class NetworkError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'NETWORK_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class FileError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'FILE_ERROR', false, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport class BrowserError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'BROWSER_ERROR', true, context)\n\t\tObject.freeze(this)\n\t}\n}\nexport function isAppError(err: unknown): err is AppError {\n\treturn err instanceof AppError\n}\nexport function isRetryableError(err: unknown): boolean {\n\treturn isAppError(err) && err.retryable\n}\nexport function isErrorWithCode(err: unknown, code: string): boolean {\n\treturn isAppError(err) && err.code === code\n}\n","export const DEFAULTS = {\n\tuserAgent:\n\t\t'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',\n\theadless: true,\n\ttimeout: 60000,\n\tdownloadButtonTimeout: 30000,\n\tfallbackWaitMs: 3000,\n\tretries: 3,\n\tretryDelay: 1000,\n\tmaxRetryDelay: 30000,\n\tsaveDebugArtifacts: true,\n\tmaxFilenameLength: 255,\n\tsanitizeReplacement: '_',\n} as const\nexport type Defaults = typeof DEFAULTS\n","import { Page } from 'playwright'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError } from '../errors/index.js'\nexport class SfilePageInteractions {\n\tconstructor(\n\t\tprivate page: Page,\n\t\tprivate logger: Logger,\n\t) {}\n\tasync waitForDownloadButton(timeout: number): Promise<void> {\n\t\tthis.logger.debug('Waiting for #download button', { timeout })\n\t\tconst button = this.page.locator('#download')\n\t\tawait button.waitFor({ state: 'visible', timeout })\n\t\tthis.logger.debug('Button is visible, checking if active')\n\t\tawait this.page.waitForFunction(\n\t\t\t() => {\n\t\t\t\tconst btn = document.querySelector('#download') as HTMLAnchorElement | null\n\t\t\t\tif (!btn) return false\n\t\t\t\tconst href = btn.getAttribute('href')\n\t\t\t\tconst style = window.getComputedStyle(btn)\n\t\t\t\tconst isDisabled =\n\t\t\t\t\tbtn.hasAttribute('disabled') ||\n\t\t\t\t\tbtn.getAttribute('aria-disabled') === 'true' ||\n\t\t\t\t\tbtn.classList.contains('disabled')\n\t\t\t\treturn !!(\n\t\t\t\t\thref &&\n\t\t\t\t\thref !== '#' &&\n\t\t\t\t\thref.trim() !== '' &&\n\t\t\t\t\tstyle.pointerEvents !== 'none' &&\n\t\t\t\t\t!isDisabled\n\t\t\t\t)\n\t\t\t},\n\t\t\t{ timeout },\n\t\t)\n\t\tthis.logger.debug('Download button is active and ready')\n\t}\n\tasync extractIntermediateUrl(): Promise<string> {\n\t\tthis.logger.debug('Extracting href from #download button')\n\t\ttry {\n\t\t\tconst href = await this.page.$eval('#download', (el) => {\n\t\t\t\tconst anchor = el as HTMLAnchorElement\n\t\t\t\treturn anchor.href\n\t\t\t})\n\t\t\tif (!href || href === '#' || href.trim() === '') {\n\t\t\t\tthrow new NetworkError('Download button href is empty or invalid', { href })\n\t\t\t}\n\t\t\treturn href\n\t\t} catch (err: unknown) {\n\t\t\tif (err instanceof Error && err.message?.includes('Element not found')) {\n\t\t\t\tthrow new NetworkError('Download button (#download) not found in page', {\n\t\t\t\t\tselector: '#download',\n\t\t\t\t\toriginalError: err.message,\n\t\t\t\t})\n\t\t\t}\n\t\t\tthrow err\n\t\t}\n\t}\n}\n","export function sanitizeFilename(name: string, replacement = '_'): string {\n\tconst safeName = name.replace(/\\.\\.[\\\\/]/g, '')\n\tconst sanitized = safeName\n\t\t.replace(/[<>:\"/\\\\|?*\\x00-\\x1F]/g, replacement)\n\t\t.replace(new RegExp(`${replacement}+`, 'g'), replacement)\n\t\t.trim()\n\tconst maxLength = 255\n\tconst trimmed = sanitized.slice(0, maxLength)\n\treturn trimmed || `file${replacement}bin`\n}\nexport const sleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms))\nexport function safeStringify(value: unknown, indent = 0): string {\n\ttry {\n\t\tconst seen = new WeakSet()\n\t\treturn JSON.stringify(\n\t\t\tvalue,\n\t\t\t(_key, val) => {\n\t\t\t\tif (typeof val === 'object' && val !== null) {\n\t\t\t\t\tif (seen.has(val)) return '[Circular]'\n\t\t\t\t\tseen.add(val)\n\t\t\t\t}\n\t\t\t\tif (typeof val === 'bigint') return val.toString() + 'n'\n\t\t\t\tif (val instanceof Error) {\n\t\t\t\t\treturn { name: val.name, message: val.message, stack: val.stack }\n\t\t\t\t}\n\t\t\t\treturn val\n\t\t\t},\n\t\t\tindent,\n\t\t)\n\t} catch {\n\t\treturn '[unserializable]'\n\t}\n}\nexport function extractFilenameFromContentDisposition(header: string | undefined): string | null {\n\tif (!header) return null\n\tconst encodedMatch = header.match(/filename\\*=UTF-8''([^;\\n\"]+)/i)\n\tif (encodedMatch?.[1]) {\n\t\ttry {\n\t\t\treturn decodeURIComponent(encodedMatch[1])\n\t\t} catch {}\n\t}\n\tconst quotedMatch = header.match(/filename\\s*=\\s*\"([^\"]+)\"/i)\n\tif (quotedMatch?.[1]) return quotedMatch[1]\n\tconst plainMatch = header.match(/filename\\s*=\\s*([^;,\\n\"]+)/i)\n\tif (plainMatch?.[1]) return plainMatch[1].trim()\n\treturn null\n}\nexport function calculateRetryDelay(\n\tattempt: number,\n\tbaseDelayMs: number,\n\tmaxDelayMs = 30000,\n): number {\n\tconst exponential = baseDelayMs * Math.pow(2, attempt - 1)\n\tconst jitter = Math.random() * 0.3 * exponential\n\treturn Math.min(exponential + jitter, maxDelayMs)\n}\nexport function isError(value: unknown): value is Error {\n\treturn (\n\t\tvalue instanceof Error ||\n\t\t(typeof value === 'object' && value !== null && 'message' in value)\n\t)\n}\n","import { chromium, Browser, BrowserContext, Page, Download, Response } from 'playwright'\nimport * as fs from 'fs/promises'\nimport path from 'path'\nimport os from 'os'\nimport { Logger } from '../utils/logger.js'\nimport { BrowserError, NetworkError } from '../errors/index.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { SfilePageInteractions } from './page-interactions.js'\nimport { sleep, extractFilenameFromContentDisposition } from '../utils/helpers.js'\nexport interface BrowserManagerOptions {\n\theadless: boolean\n\tuserAgent: string\n\ttimeout: number\n\tdebug: boolean\n\tdownloadButtonTimeout?: number\n}\nexport class BrowserManager {\n\tprivate browser: Browser | null = null\n\tprivate context: BrowserContext | null = null\n\tprivate page: Page | null = null\n\tprivate interactions: SfilePageInteractions | null = null\n\tprivate debugDir: string | null = null\n\tprivate readonly stageHistory: Array<{ stage: string; ts: number }> = []\n\tconstructor(\n\t\tprivate logger: Logger,\n\t\tprivate opts: BrowserManagerOptions,\n\t) {}\n\tprivate trackStage(stage: string): void {\n\t\tthis.stageHistory.push({ stage, ts: Date.now() })\n\t}\n\tasync launch(): Promise<void> {\n\t\tconst stage = 'launch'\n\t\tthis.trackStage(stage)\n\t\ttry {\n\t\t\tthis.logger.info('Launching browser', { headless: this.opts.headless })\n\t\t\tthis.browser = await chromium.launch({\n\t\t\t\theadless: this.opts.headless,\n\t\t\t\targs: [\n\t\t\t\t\t'--no-sandbox',\n\t\t\t\t\t'--disable-setuid-sandbox',\n\t\t\t\t\t'--disable-dev-shm-usage',\n\t\t\t\t\t'--disable-accelerated-2d-canvas',\n\t\t\t\t\t'--no-first-run',\n\t\t\t\t\t'--no-zygote',\n\t\t\t\t],\n\t\t\t})\n\t\t\tthis.context = await this.browser.newContext({\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t\tacceptDownloads: true,\n\t\t\t\tlocale: 'en-US',\n\t\t\t\ttimezoneId: 'UTC',\n\t\t\t\tviewport: { width: 1280, height: 720 },\n\t\t\t})\n\t\t\tawait this.context.addCookies([\n\t\t\t\t{\n\t\t\t\t\tname: 'safe_link_counter',\n\t\t\t\t\tvalue: '1',\n\t\t\t\t\tdomain: '.sfile.co',\n\t\t\t\t\tpath: '/',\n\t\t\t\t\texpires: Math.floor(Date.now() / 1000) + 3600,\n\t\t\t\t},\n\t\t\t])\n\t\t\tthis.page = await this.context.newPage()\n\t\t\tthis.interactions = new SfilePageInteractions(this.page, this.logger)\n\t\t\tif (this.opts.debug) {\n\t\t\t\tthis.setupDebugListeners()\n\t\t\t}\n\t\t\tthis.logger.info('Browser ready')\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new BrowserError(`Failed to launch browser: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t\tuserAgent: this.opts.userAgent,\n\t\t\t})\n\t\t}\n\t}\n\tprivate setupDebugListeners(): void {\n\t\tif (!this.page) return\n\t\tthis.page.on('console', (msg) => {\n\t\t\tconst type = msg.type()\n\t\t\tconst text = msg.text()\n\t\t\tif (type === 'error') {\n\t\t\t\tthis.logger.error(`[console] ${text}`, { location: msg.location() })\n\t\t\t} else if (type === 'warning') {\n\t\t\t\tthis.logger.warn(`[console] ${text}`)\n\t\t\t} else if (type === 'debug') {\n\t\t\t\tthis.logger.debug(`[console] ${text}`)\n\t\t\t}\n\t\t})\n\t\tthis.page.on('pageerror', (err) => {\n\t\t\tthis.logger.error('[pageerror]', undefined, err)\n\t\t})\n\t\tthis.page.on('requestfailed', (req) => {\n\t\t\tconst failure = req.failure()\n\t\t\tthis.logger.warn('[requestfailed]', {\n\t\t\t\turl: req.url(),\n\t\t\t\tmethod: req.method(),\n\t\t\t\terror: failure?.errorText,\n\t\t\t})\n\t\t})\n\t}\n\tasync goto(\n\t\turl: string,\n\t\twaitUntil: 'load' | 'networkidle' | 'commit' | 'domcontentloaded' = 'networkidle',\n\t): Promise<void> {\n\t\tconst stage = 'navigation'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\ttry {\n\t\t\tthis.logger.debug(`Navigating to ${url}`, { waitUntil, timeout: this.opts.timeout })\n\t\t\tawait this.page.goto(url, { waitUntil, timeout: this.opts.timeout })\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Navigation failed: ${err.message}`, {\n\t\t\t\turl,\n\t\t\t\tstage,\n\t\t\t\twaitUntil,\n\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync waitForDownloadButton(): Promise<void> {\n\t\tconst stage = 'waitForButton'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\tconst timeout = this.opts.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout\n\t\ttry {\n\t\t\tawait this.interactions.waitForDownloadButton(timeout)\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to wait for download button: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\ttimeout,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync getIntermediateUrl(): Promise<string> {\n\t\tconst stage = 'extractUrl'\n\t\tthis.trackStage(stage)\n\t\tif (!this.interactions) {\n\t\t\tthrow new BrowserError('Interactions not ready', { stage })\n\t\t}\n\t\ttry {\n\t\t\tconst url = await this.interactions.extractIntermediateUrl()\n\t\t\tthis.logger.debug('Intermediate URL extracted', { url })\n\t\t\treturn url\n\t\t} catch (err: any) {\n\t\t\tawait this.handleStageError(stage, err)\n\t\t\tthrow new NetworkError(`Failed to extract intermediate URL: ${err.message}`, {\n\t\t\t\tstage,\n\t\t\t\toriginalError: err.message,\n\t\t\t})\n\t\t}\n\t}\n\tasync startDownloadAndWait(autoUrl: string): Promise<Download | null> {\n\t\tconst stage = 'downloadWait'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tconst downloadPromise = this.page\n\t\t\t.waitForEvent('download', { timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.debug('Download event timeout', {\n\t\t\t\t\ttimeout: this.opts.timeout,\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t\treturn null\n\t\t\t})\n\t\tthis.logger.debug('Navigating to auto download URL', { url: autoUrl })\n\t\tawait this.page\n\t\t\t.goto(autoUrl, { waitUntil: 'commit', timeout: this.opts.timeout })\n\t\t\t.catch((err) => {\n\t\t\t\tthis.logger.warn('Navigation to auto URL failed, continuing anyway', {\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t})\n\t\tconst download = await downloadPromise\n\t\tif (download) {\n\t\t\tthis.logger.info('Download event captured')\n\t\t\treturn download\n\t\t}\n\t\tthis.logger.debug('No download event captured within timeout')\n\t\treturn null\n\t}\n\tasync fallbackCollectFileResponse(): Promise<{ buffer: Buffer; filename: string } | null> {\n\t\tconst stage = 'fallbackIntercept'\n\t\tthis.trackStage(stage)\n\t\tif (!this.page) {\n\t\t\tthrow new BrowserError('Page not initialized', { stage })\n\t\t}\n\t\tthis.logger.info('Falling back to response interception')\n\t\tconst responses: Response[] = []\n\t\tconst handler = (res: Response) => responses.push(res)\n\t\tthis.page.on('response', handler)\n\t\tawait sleep(DEFAULTS.fallbackWaitMs)\n\t\tthis.page.off('response', handler)\n\t\tconst fileResponse = [...responses].reverse().find((r) => {\n\t\t\tconst headers = r.headers()\n\t\t\tconst disposition = headers['content-disposition']\n\t\t\tconst contentType = headers['content-type']\n\t\t\tconst url = r.url()\n\t\t\treturn (\n\t\t\t\t(disposition && disposition.includes('attachment')) ||\n\t\t\t\turl.includes('/downloadfile/') ||\n\t\t\t\t(contentType &&\n\t\t\t\t\t!contentType.startsWith('text/html') &&\n\t\t\t\t\t!contentType.startsWith('application/json'))\n\t\t\t)\n\t\t})\n\t\tif (!fileResponse) {\n\t\t\tthis.logger.debug('No suitable file response found in fallback', {\n\t\t\t\tresponseCount: responses.length,\n\t\t\t\tsampleUrls: responses.slice(0, 3).map((r) => r.url()),\n\t\t\t})\n\t\t\treturn null\n\t\t}\n\t\ttry {\n\t\t\tconst buffer = await fileResponse.body()\n\t\t\tlet filename = extractFilenameFromContentDisposition(\n\t\t\t\tfileResponse.headers()['content-disposition'],\n\t\t\t)\n\t\t\tif (!filename) {\n\t\t\t\tconst urlParts = fileResponse.url().split('/')\n\t\t\t\tfilename = urlParts[urlParts.length - 1]?.split('?')[0] || 'file.bin'\n\t\t\t}\n\t\t\tfilename = filename.replace(/[<>:\"/\\\\|?*]/g, '_')\n\t\t\tthis.logger.info('Fallback response captured', {\n\t\t\t\tfilename,\n\t\t\t\tsize: buffer.length,\n\t\t\t\tcontentType: fileResponse.headers()['content-type'],\n\t\t\t})\n\t\t\treturn { buffer, filename }\n\t\t} catch (err: any) {\n\t\t\tthis.logger.error('Failed to read fallback response body', { error: err.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tasync saveDebugArtifacts(errorMessage: string): Promise<string | null> {\n\t\tif (!this.opts.debug || !this.page) return null\n\t\ttry {\n\t\t\tthis.debugDir = path.join(\n\t\t\t\tos.tmpdir(),\n\t\t\t\t`sfile_debug_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,\n\t\t\t)\n\t\t\tawait fs.mkdir(this.debugDir, { recursive: true })\n\t\t\tconst tasks: Promise<void>[] = [\n\t\t\t\tthis.page\n\t\t\t\t\t.screenshot({\n\t\t\t\t\t\tpath: path.join(this.debugDir, 'error.png'),\n\t\t\t\t\t\tfullPage: true,\n\t\t\t\t\t})\n\t\t\t\t\t.then(() => {}),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.html'), await this.page.content()),\n\t\t\t\tfs.writeFile(path.join(this.debugDir, 'error.txt'), errorMessage),\n\t\t\t\tfs.writeFile(\n\t\t\t\t\tpath.join(this.debugDir, 'stages.json'),\n\t\t\t\t\tJSON.stringify(this.stageHistory, null, 2),\n\t\t\t\t),\n\t\t\t]\n\t\t\tawait Promise.all(tasks)\n\t\t\tthis.logger.info('Debug artifacts saved', { debugDir: this.debugDir })\n\t\t\treturn this.debugDir\n\t\t} catch (e: any) {\n\t\t\tthis.logger.error('Failed to save debug artifacts', { error: e.message })\n\t\t\treturn null\n\t\t}\n\t}\n\tprivate async handleStageError(stage: string, error: any): Promise<void> {\n\t\tif (this.opts.debug) {\n\t\t\tawait this.saveDebugArtifacts(\n\t\t\t\t`Error at stage \"${stage}\": ${error?.message || 'Unknown error'}`,\n\t\t\t)\n\t\t}\n\t}\n\tasync close(): Promise<void> {\n\t\tconst closePromises = [\n\t\t\tthis.page?.close().catch(() => {}),\n\t\t\tthis.context?.close().catch(() => {}),\n\t\t\tthis.browser?.close().catch(() => {}),\n\t\t].filter(Boolean) as Promise<void>[]\n\t\tawait Promise.all(closePromises)\n\t\tthis.logger.debug('Browser closed', { stages: this.stageHistory.length })\n\t}\n\tasync getPage(): Promise<Page | null> {\n\t\treturn this.page\n\t}\n\tgetDebugDir(): string | null {\n\t\treturn this.debugDir\n\t}\n\tgetStageHistory(): ReadonlyArray<{ stage: string; ts: number }> {\n\t\treturn [...this.stageHistory]\n\t}\n}\n","import { createWriteStream, type WriteStream } from 'fs'\nimport { safeStringify } from './helpers.js'\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error'\nexport interface LoggerOptions {\n\tdebugMode?: boolean\n\tcorrelationId?: string\n\tlogFile?: string\n\tprefix?: string\n}\nexport class Logger {\n\tprivate minLevel: LogLevel\n\tprivate correlationId: string | undefined\n\tprivate fileStream: WriteStream | null = null\n\tprivate prefix: string\n\tconstructor(options: LoggerOptions = {}) {\n\t\tthis.minLevel = options.debugMode ? 'debug' : 'info'\n\t\tthis.correlationId = options.correlationId\n\t\tthis.prefix = options.prefix || ''\n\t\tif (options.logFile) {\n\t\t\tthis.fileStream = createWriteStream(options.logFile, { flags: 'a' })\n\t\t}\n\t}\n\tsetCorrelationId(id: string): void {\n\t\tthis.correlationId = id\n\t}\n\tsetDebug(enabled: boolean): void {\n\t\tthis.minLevel = enabled ? 'debug' : 'info'\n\t}\n\tprivate levelPriority(level: LogLevel): number {\n\t\treturn { debug: 0, info: 1, warn: 2, error: 3 }[level]\n\t}\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn this.levelPriority(level) >= this.levelPriority(this.minLevel)\n\t}\n\tprivate format(level: LogLevel, message: string, context?: unknown): string {\n\t\tconst ts = new Date().toISOString()\n\t\tconst corr = this.correlationId ? ` [${this.correlationId}]` : ''\n\t\tconst prefix = this.prefix ? ` [${this.prefix}]` : ''\n\t\tconst ctx = context ? ` | ${safeStringify(context)}` : ''\n\t\treturn `[${ts}]${corr}${prefix} ${level.toUpperCase()}: ${message}${ctx}`\n\t}\n\tprivate write(level: LogLevel, message: string, context?: unknown): void {\n\t\tif (!this.shouldLog(level)) return\n\t\tconst formatted = this.format(level, message, context)\n\t\tconst consoleMethod = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log'\n\t\tconsole[consoleMethod](formatted)\n\t\tif (this.fileStream?.writable) {\n\t\t\tthis.fileStream.write(formatted + '\\n')\n\t\t}\n\t}\n\tdebug(msg: string, ctx?: unknown): void {\n\t\tthis.write('debug', msg, ctx)\n\t}\n\tinfo(msg: string, ctx?: unknown): void {\n\t\tthis.write('info', msg, ctx)\n\t}\n\twarn(msg: string, ctx?: unknown): void {\n\t\tthis.write('warn', msg, ctx)\n\t}\n\terror(msg: string, ctx?: unknown, err?: Error): void {\n\t\tlet errorCtx: unknown\n\t\tif (err) {\n\t\t\tconst baseObj =\n\t\t\t\tctx && typeof ctx === 'object' && ctx !== null\n\t\t\t\t\t? { ...(ctx as Record<string, unknown>) }\n\t\t\t\t\t: {}\n\t\t\terrorCtx = {\n\t\t\t\t...baseObj,\n\t\t\t\terror: { name: err.name, message: err.message },\n\t\t\t}\n\t\t} else {\n\t\t\terrorCtx = ctx\n\t\t}\n\t\tthis.write('error', msg, errorCtx)\n\t}\n\tchild(prefix: string): Logger {\n\t\tconst childOptions: LoggerOptions = {\n\t\t\tdebugMode: this.minLevel === 'debug',\n\t\t\t...(this.correlationId !== undefined && { correlationId: this.correlationId }),\n\t\t\tprefix: this.prefix ? `${this.prefix}:${prefix}` : prefix,\n\t\t}\n\t\tconst child = new Logger(childOptions)\n\t\tif (this.fileStream) {\n\t\t\t;(child as any).fileStream = this.fileStream\n\t\t}\n\t\treturn child\n\t}\n\tasync close(): Promise<void> {\n\t\tif (this.fileStream && !this.fileStream.closed) {\n\t\t\treturn new Promise((resolve) => this.fileStream?.end(resolve))\n\t\t}\n\t}\n}\n","import { DEFAULTS } from './defaults.js'\nexport interface DownloadOptions {\n\theadless?: boolean\n\tuserAgent?: string\n\ttimeout?: number\n\tdownloadButtonTimeout?: number\n\tretries?: number\n\tretryDelay?: number\n\tonProgress?: (\n\t\tpercent: number,\n\t\ttotal: 100,\n\t\tmeta: { stage: string; message: string; attempt?: number },\n\t) => void\n\tcorrelationId?: string\n\tdebug?: boolean\n\tsaveDebugArtifacts?: boolean\n\tlogFile?: string\n\t_internal?: {\n\t\tstage?: string\n\t}\n}\nexport interface DownloadResult {\n\tfilePath: string\n\tsize: number\n\tmethod: 'direct' | 'fallback'\n\tcorrelationId?: string\n\tdurationMs?: number\n\tattempts?: number\n}\ntype NormalizedOptions = Required<\n\tOmit<DownloadOptions, 'onProgress' | 'correlationId' | '_internal' | 'logFile'>\n> & {\n\tonProgress?: DownloadOptions['onProgress']\n\tcorrelationId?: string\n\t_internal?: DownloadOptions['_internal']\n\tlogFile?: string\n}\nexport function normalizeOptions(opts?: DownloadOptions): NormalizedOptions {\n\tconst base = {\n\t\theadless: opts?.headless ?? DEFAULTS.headless,\n\t\tuserAgent: opts?.userAgent ?? DEFAULTS.userAgent,\n\t\ttimeout: opts?.timeout ?? DEFAULTS.timeout,\n\t\tdownloadButtonTimeout: opts?.downloadButtonTimeout ?? DEFAULTS.downloadButtonTimeout,\n\t\tretries: opts?.retries ?? DEFAULTS.retries,\n\t\tretryDelay: opts?.retryDelay ?? DEFAULTS.retryDelay,\n\t\tdebug: opts?.debug ?? false,\n\t\tsaveDebugArtifacts: opts?.saveDebugArtifacts ?? DEFAULTS.saveDebugArtifacts,\n\t}\n\tconst optional = {\n\t\t...(opts?.onProgress !== undefined && { onProgress: opts.onProgress }),\n\t\t...(opts?.correlationId !== undefined && { correlationId: opts.correlationId }),\n\t\t...(opts?._internal !== undefined && { _internal: opts._internal }),\n\t\t...(opts?.logFile !== undefined && { logFile: opts.logFile }),\n\t}\n\treturn { ...base, ...optional } as NormalizedOptions\n}\n","import { ValidationError } from '../errors/index.js'\nimport { sanitizeFilename } from '../utils/helpers.js'\nimport { DEFAULTS } from '../config/defaults.js'\nexport class InputValidator {\n\tstatic validateUrl(\n\t\turl: unknown,\n\t\tallowedDomains: readonly string[] = ['sfile.co', 'sfile.mobi'],\n\t): asserts url is string {\n\t\tif (!url || typeof url !== 'string') {\n\t\t\tthrow new ValidationError('URL must be a non-empty string', {\n\t\t\t\treceived: typeof url,\n\t\t\t\turl,\n\t\t\t})\n\t\t}\n\t\tconst hasAllowedDomain = allowedDomains.some((domain) => url.includes(domain))\n\t\tif (!hasAllowedDomain) {\n\t\t\tthrow new ValidationError(`URL must contain one of: ${allowedDomains.join(', ')}`, {\n\t\t\t\turl,\n\t\t\t\tallowedDomains,\n\t\t\t})\n\t\t}\n\t\ttry {\n\t\t\tconst parsed = new URL(url)\n\t\t\tif (!['http:', 'https:'].includes(parsed.protocol)) {\n\t\t\t\tthrow new ValidationError('URL must use http or https protocol', {\n\t\t\t\t\turl,\n\t\t\t\t\tprotocol: parsed.protocol,\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (parseErr) {\n\t\t\tthrow new ValidationError('Invalid URL format', {\n\t\t\t\turl,\n\t\t\t\tparseError: parseErr instanceof Error ? parseErr.message : String(parseErr),\n\t\t\t})\n\t\t}\n\t}\n\tstatic validateSaveDir(dir: unknown): asserts dir is string {\n\t\tif (!dir || typeof dir !== 'string') {\n\t\t\tthrow new ValidationError('Save directory must be a non-empty string', {\n\t\t\t\treceived: typeof dir,\n\t\t\t\tdir,\n\t\t\t})\n\t\t}\n\t}\n\tstatic sanitizeFilename(name: string): string {\n\t\tconst replacement = DEFAULTS.sanitizeReplacement\n\t\tconst maxLength = DEFAULTS.maxFilenameLength\n\t\tconst sanitized = sanitizeFilename(name, replacement)\n\t\tif (!sanitized || sanitized.length === 0) {\n\t\t\tconst ext = name.includes('.') ? name.split('.').pop() : 'bin'\n\t\t\treturn `downloaded_file${ext ? '.' + ext : ''}`.slice(0, maxLength)\n\t\t}\n\t\treturn sanitized.slice(0, maxLength)\n\t}\n\tstatic validateOptions(options: unknown): void {\n\t\tif (options === undefined || options === null) {\n\t\t\treturn\n\t\t}\n\t\tif (typeof options !== 'object') {\n\t\t\tthrow new ValidationError('Options must be an object or undefined', {\n\t\t\t\treceived: typeof options,\n\t\t\t})\n\t\t}\n\t\tconst opts = options as Record<string, unknown>\n\t\tconst numericFields = ['timeout', 'retries', 'retryDelay', 'downloadButtonTimeout'] as const\n\t\tfor (const field of numericFields) {\n\t\t\tif (field in opts && opts[field] !== undefined && typeof opts[field] !== 'number') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a number`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst booleanFields = ['headless', 'debug', 'saveDebugArtifacts'] as const\n\t\tfor (const field of booleanFields) {\n\t\t\tif (field in opts && opts[field] !== undefined && typeof opts[field] !== 'boolean') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a boolean`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tconst stringFields = ['correlationId', 'logFile', 'userAgent'] as const\n\t\tfor (const field of stringFields) {\n\t\t\tif (field in opts && opts[field] !== undefined && typeof opts[field] !== 'string') {\n\t\t\t\tthrow new ValidationError(`Option '${field}' must be a string`, {\n\t\t\t\t\tfield,\n\t\t\t\t\treceived: typeof opts[field],\n\t\t\t\t\tvalue: opts[field],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\t'onProgress' in opts &&\n\t\t\topts['onProgress'] !== undefined &&\n\t\t\ttypeof opts['onProgress'] !== 'function'\n\t\t) {\n\t\t\tthrow new ValidationError(`Option 'onProgress' must be a function`, {\n\t\t\t\treceived: typeof opts['onProgress'],\n\t\t\t})\n\t\t}\n\t}\n}\n","import * as path from 'path'\nimport { promises as fs } from 'fs'\nimport { randomUUID } from 'crypto'\nimport { BrowserManager } from '../browser/browser-manager.js'\nimport { Logger } from '../utils/logger.js'\nimport { NetworkError, AppError } from '../errors/index.js'\nimport { DownloadOptions, DownloadResult, normalizeOptions } from '../config/schema.js'\nimport { DEFAULTS } from '../config/defaults.js'\nimport { InputValidator } from './validator.js'\nimport { sleep, calculateRetryDelay } from '../utils/helpers.js'\nfunction stripUndefined<T extends Record<string, unknown>>(obj: T): T {\n\treturn Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as T\n}\nfunction safeProgress(\n\tonProgress: unknown,\n\tpercent: number,\n\ttotal: number,\n\tmeta: Record<string, unknown>,\n): void {\n\tif (typeof onProgress === 'function') {\n\t\ttry {\n\t\t\t;(onProgress as any)(percent, total, meta)\n\t\t} catch (err) {\n\t\t\tconsole.warn('Progress callback error:', err)\n\t\t}\n\t}\n}\nasync function executeDownload(\n\turl: string,\n\tsaveDir: string,\n\topts: ReturnType<typeof normalizeOptions>,\n\tlogger: Logger,\n): Promise<DownloadResult> {\n\tconst startTime = Date.now()\n\tconst browserMgr = new BrowserManager(logger.child('BrowserManager'), {\n\t\theadless: opts.headless,\n\t\tuserAgent: opts.userAgent,\n\t\ttimeout: opts.timeout,\n\t\tdebug: opts.debug,\n\t\tdownloadButtonTimeout: opts.downloadButtonTimeout,\n\t})\n\tlet finalPath: string\n\tlet fileSize: number\n\tlet method: 'direct' | 'fallback'\n\ttry {\n\t\tlogger.info('Starting download workflow', { url })\n\t\tsafeProgress(opts.onProgress, 10, 100, {\n\t\t\tstage: 'launch',\n\t\t\tmessage: 'Launching browser',\n\t\t\tattempt: 1,\n\t\t})\n\t\tawait browserMgr.launch()\n\t\tawait browserMgr.goto(url, 'networkidle')\n\t\tsafeProgress(opts.onProgress, 30, 100, { stage: 'navigation', message: 'Page loaded' })\n\t\tawait browserMgr.waitForDownloadButton()\n\t\tsafeProgress(opts.onProgress, 50, 100, {\n\t\t\tstage: 'button',\n\t\t\tmessage: 'Download button ready',\n\t\t})\n\t\tconst intermediateUrl = await browserMgr.getIntermediateUrl()\n\t\tconst autoUrl = intermediateUrl.includes('?')\n\t\t\t? `${intermediateUrl}&auto=1`\n\t\t\t: `${intermediateUrl}?auto=1`\n\t\tlogger.debug('Triggering download', { autoUrl })\n\t\tsafeProgress(opts.onProgress, 70, 100, { stage: 'trigger', message: 'Download triggered' })\n\t\tlet download = await browserMgr.startDownloadAndWait(autoUrl)\n\t\tif (download) {\n\t\t\tconst suggested = download.suggestedFilename() || 'file.bin'\n\t\t\tconst filename = InputValidator.sanitizeFilename(suggested)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait download.saveAs(finalPath)\n\t\t\tconst stat = await fs.stat(finalPath)\n\t\t\tfileSize = stat.size\n\t\t\tmethod = 'direct'\n\t\t\tlogger.info('Saved via direct download', { path: finalPath, size: fileSize })\n\t\t} else {\n\t\t\tlogger.warn('Direct download not captured, trying fallback')\n\t\t\tconst fallback = await browserMgr.fallbackCollectFileResponse()\n\t\t\tif (!fallback) {\n\t\t\t\tthrow new NetworkError('No download event and no file response found', {\n\t\t\t\t\turl,\n\t\t\t\t\tintermediateUrl,\n\t\t\t\t\tautoUrl,\n\t\t\t\t\tstage: 'fallbackFailed',\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst { buffer, filename: rawName } = fallback\n\t\t\tconst filename = InputValidator.sanitizeFilename(rawName)\n\t\t\tfinalPath = path.join(saveDir, filename)\n\t\t\tawait fs.writeFile(finalPath, buffer)\n\t\t\tfileSize = buffer.length\n\t\t\tmethod = 'fallback'\n\t\t\tlogger.info('Saved via fallback', { path: finalPath, size: fileSize })\n\t\t}\n\t\tsafeProgress(opts.onProgress, 100, 100, { stage: 'complete', message: 'Download finished' })\n\t\tconst result: DownloadResult = {\n\t\t\tfilePath: finalPath,\n\t\t\tsize: fileSize,\n\t\t\tmethod,\n\t\t\tdurationMs: Date.now() - startTime,\n\t\t\tattempts: 1,\n\t\t}\n\t\tif (opts.correlationId !== undefined) {\n\t\t\tresult.correlationId = opts.correlationId\n\t\t}\n\t\treturn result\n\t} catch (err: unknown) {\n\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\tconst appError =\n\t\t\terror instanceof AppError\n\t\t\t\t? error\n\t\t\t\t: new NetworkError(error.message, {\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tsaveDir,\n\t\t\t\t\t\tcorrelationId: opts.correlationId,\n\t\t\t\t\t\toriginalError: error.message,\n\t\t\t\t\t\terrorName: error.name,\n\t\t\t\t\t})\n\t\tif (opts.saveDebugArtifacts) {\n\t\t\tconst debugPath = await browserMgr.saveDebugArtifacts(appError.message)\n\t\t\tif (debugPath) {\n\t\t\t\t;(appError as any).debugPath = debugPath\n\t\t\t\tif (appError.context && typeof appError.context === 'object') {\n\t\t\t\t\t;(appError.context as any).debugPath = debugPath\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow appError\n\t} finally {\n\t\tawait browserMgr\n\t\t\t.close()\n\t\t\t.catch((e) => logger.error('Failed to close browser', { error: e.message }))\n\t\tawait logger.close().catch((e) => console.error('Failed to close logger', e))\n\t}\n}\nexport async function downloadSfile(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<DownloadResult> {\n\tconst opts = normalizeOptions(options)\n\tconst correlationId = opts.correlationId || randomUUID()\n\ttype LoggerConstructorParams = ConstructorParameters<typeof Logger>\n\ttype LoggerOptionsType = LoggerConstructorParams[0]\n\tconst loggerOptions: LoggerOptionsType = {\n\t\tdebugMode: opts.debug,\n\t\tcorrelationId,\n\t\tprefix: 'downloadSfile',\n\t}\n\tif (opts.logFile !== undefined) {\n\t\tloggerOptions.logFile = opts.logFile\n\t}\n\tconst logger = new Logger(loggerOptions)\n\tInputValidator.validateUrl(url)\n\tInputValidator.validateSaveDir(saveDir)\n\tInputValidator.validateOptions(options)\n\tawait fs.mkdir(saveDir, { recursive: true })\n\tlet lastError: Error | undefined\n\tlet attempt = 0\n\twhile (attempt < opts.retries) {\n\t\tattempt++\n\t\ttry {\n\t\t\tlogger.info(`Download attempt ${attempt}/${opts.retries}`, { url })\n\t\t\tconst result = await executeDownload(url, saveDir, opts, logger)\n\t\t\tlogger.info(`Download succeeded`, {\n\t\t\t\tduration: result.durationMs,\n\t\t\t\tattempts: attempt,\n\t\t\t\tmethod: result.method,\n\t\t\t})\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattempts: attempt,\n\t\t\t\tcorrelationId,\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tlastError = err instanceof Error ? err : new Error(String(err))\n\t\t\tconst isRetryable = lastError instanceof AppError && lastError.retryable\n\t\t\tconst isLastAttempt = attempt >= opts.retries\n\t\t\tif (!isRetryable || isLastAttempt) {\n\t\t\t\tlogger.error(`Download failed permanently`, {\n\t\t\t\t\terror: lastError.message,\n\t\t\t\t\tattempt,\n\t\t\t\t\tretryable: isRetryable,\n\t\t\t\t\tlastAttempt: isLastAttempt,\n\t\t\t\t})\n\t\t\t\tthrow lastError\n\t\t\t}\n\t\t\tconst delay = calculateRetryDelay(attempt, opts.retryDelay, DEFAULTS.maxRetryDelay)\n\t\t\tlogger.warn(`Retrying download`, {\n\t\t\t\tattempt,\n\t\t\t\tmaxAttempts: opts.retries,\n\t\t\t\tdelayMs: Math.round(delay),\n\t\t\t\terror: lastError.message,\n\t\t\t})\n\t\t\tsafeProgress(opts.onProgress, 0, 100, {\n\t\t\t\tstage: 'retry',\n\t\t\t\tmessage: `Retry ${attempt}/${opts.retries}`,\n\t\t\t\tattempt,\n\t\t\t})\n\t\t\tawait sleep(delay)\n\t\t}\n\t}\n\tthrow lastError || new Error('Download failed after all retries')\n}\nexport async function downloadSfileSafe(\n\turl: string,\n\tsaveDir: string,\n\toptions?: DownloadOptions,\n): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\ttry {\n\t\tconst result = await downloadSfile(url, saveDir, options)\n\t\treturn { success: true, value: result }\n\t} catch (error) {\n\t\treturn { success: false, error: error as Error }\n\t}\n}\nexport function createDownloader(defaultOptions?: DownloadOptions) {\n\tconst defaults = normalizeOptions(defaultOptions)\n\treturn {\n\t\tasync download(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<DownloadResult> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfile(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\tasync downloadSafe(\n\t\t\turl: string,\n\t\t\tsaveDir: string,\n\t\t\tcallOptions?: DownloadOptions,\n\t\t): Promise<import('../utils/result.js').Result<DownloadResult, Error>> {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...callOptions })\n\t\t\treturn downloadSfileSafe(url, saveDir, merged as DownloadOptions)\n\t\t},\n\t\twithOptions(newDefaults: Partial<DownloadOptions>) {\n\t\t\tconst merged = stripUndefined({ ...defaults, ...newDefaults })\n\t\t\treturn createDownloader(merged as DownloadOptions)\n\t\t},\n\t}\n}\n","export type Result<T, E = Error> = { success: true; value: T } | { success: false; error: E }\nexport function ok<T, E = never>(value: T): Result<T, E> {\n\treturn { success: true, value }\n}\nexport function err<E, T = never>(error: E): Result<T, E> {\n\treturn { success: false, error }\n}\nexport function isSuccess<T, E>(result: Result<T, E>): result is { success: true; value: T } {\n\treturn result.success === true\n}\nexport function isFailure<T, E>(result: Result<T, E>): result is { success: false; error: E } {\n\treturn result.success === false\n}\nexport function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {\n\tif (result.success) {\n\t\treturn { success: true, value: fn(result.value) }\n\t}\n\treturn result\n}\nexport function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F> {\n\tif (!result.success) {\n\t\treturn { success: false, error: fn(result.error) }\n\t}\n\treturn result\n}\nexport function getOrThrow<T, E>(result: Result<T, E>): T {\n\tif (result.success) return result.value\n\tthrow result.error\n}\n"],"names":["path","fs"],"mappings":";;;;;;;;AAAM,MAAgB,QAAS,SAAQ,KAAK,CAAA;AAC3B,IAAA,SAAS;AACT,IAAA,OAAO;AACP,IAAA,IAAI;AACJ,IAAA,SAAS;AACzB,IAAA,WAAA,CACC,OAAe,EACf,IAAY,EACZ,SAAA,GAAqB,KAAK,EAC1B,OAAiC,EAAA;QAEjC,KAAK,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;AACjC,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,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K,KAAK;AAChC;AAOM,SAAU,QAAQ,CAAU,MAAoB,EAAE,EAAmB,EAAA;AAC1E,IAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACpB,QAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;IACnD;AACA,IAAA,OAAO,MAAM;AACd;;;;"}
package/changelog CHANGED
@@ -1,3 +1,15 @@
1
+ commit acab839504531f5938b5777a884ca8b07ad600e8
2
+ Author: neuxdotdev <neuxdev1@gmail.com>
3
+ Date: Thu Apr 2 15:51:41 2026 +0700
4
+
5
+ docs: remkae readme
6
+
7
+ commit 79b7c856357a6098c1fc41aef071c25d4d4d6340
8
+ Author: neuxdotdev <neuxdev1@gmail.com>
9
+ Date: Thu Apr 2 15:44:21 2026 +0700
10
+
11
+ add changelog
12
+
1
13
  commit bee596315d96e819de09fc3c41be8dbf48a0cff6
2
14
  Author: neuxdotdev <neuxdev1@gmail.com>
3
15
  Date: Thu Apr 2 15:43:57 2026 +0700
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfiledl",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Implement and automate downloading of any file from sfile.co with javascripts library, written entirely in typescripts",
5
5
  "type": "module",
6
6
  "main": "./build/lib.cjs",
package/readme.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # sfiledl
2
2
 
3
- > Implement and automate downloading of any file from https://sfile.co/ with javascripts library, written entirely in typescripts
3
+ > Automate file downloads from [sfile.co](https://sfile.co/) reliable, retry‑aware, and fully typed.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/sfiledl)](https://www.npmjs.com/package/sfiledl)
6
6
  [![License](https://img.shields.io/npm/l/sfiledl)](https://github.com/neuxdotdev/sfiledl/blob/main/license)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue)](https://www.typescriptlang.org)
8
+ [![Playwright](https://img.shields.io/badge/Playwright-1.40-green)](https://playwright.dev)
8
9
 
9
10
  ---
10
11
 
@@ -18,7 +19,7 @@ bun add sfiledl
18
19
  npm install sfiledl
19
20
 
20
21
  # Install Playwright browser (required)
21
- bunx playwright install chromium
22
+ bunx playwright install chromium # or npx playwright install chromium
22
23
  ```
23
24
 
24
25
  ---
@@ -28,17 +29,16 @@ bunx playwright install chromium
28
29
  ```typescript
29
30
  import { downloadSfile } from 'sfiledl'
30
31
 
31
- const result = await downloadSfile(
32
- 'https://sfile.co/file/abc123', // sfile.co URL
33
- './downloads', // Save directory
34
- { headless: true, debug: false }, // Optional options
35
- )
32
+ const result = await downloadSfile('https://sfile.co/file/abc123', './downloads')
36
33
 
37
34
  console.log(result)
38
35
  // {
39
- // filePath: './downloads/file.zip',
36
+ // filePath: './downloads/document.pdf',
40
37
  // size: 1048576,
41
- // method: 'direct' | 'fallback'
38
+ // method: 'direct',
39
+ // correlationId: '550e8400-e29b-41d4-a716-446655440000',
40
+ // durationMs: 1234,
41
+ // attempts: 1
42
42
  // }
43
43
  ```
44
44
 
@@ -48,20 +48,63 @@ console.log(result)
48
48
 
49
49
  ### `downloadSfile(url, saveDir, options?)`
50
50
 
51
- | Parameter | Type | Required | Description |
52
- | --------- | ----------------- | -------- | -------------------------- |
53
- | `url` | `string` | | sfile.co URL to download |
54
- | `saveDir` | `string` | | Directory to save the file |
55
- | `options` | `DownloadOptions` | | Optional configuration |
51
+ Main download function. Throws errors on failure (see [Error Handling](#error-handling)).
52
+
53
+ | Param | Type | Description |
54
+ | --------- | ----------------- | -------------------------------------- |
55
+ | `url` | `string` | sfile.co URL (must contain the domain) |
56
+ | `saveDir` | `string` | Directory where the file will be saved |
57
+ | `options` | `DownloadOptions` | Optional configuration |
58
+
59
+ **Returns:** `Promise<DownloadResult>`
60
+
61
+ ### `downloadSfileSafe(url, saveDir, options?)`
62
+
63
+ Same as `downloadSfile` but never throws. Returns a `Result` object.
64
+
65
+ ```typescript
66
+ import { downloadSfileSafe, isSuccess } from 'sfiledl'
67
+
68
+ const res = await downloadSfileSafe(url, './out')
69
+ if (isSuccess(res)) {
70
+ console.log('OK:', res.value.filePath)
71
+ } else {
72
+ console.error('Error:', res.error.message)
73
+ }
74
+ ```
75
+
76
+ ### `createDownloader(defaultOptions?)`
77
+
78
+ Creates a reusable downloader with preset options.
79
+
80
+ ```typescript
81
+ const dl = createDownloader({ headless: false, debug: true })
82
+ const result = await dl.download('https://sfile.co/file/xyz', './out')
83
+ // or safe variant:
84
+ const safeResult = await dl.downloadSafe(url, './out')
85
+ // chain new defaults:
86
+ const quietDl = dl.withOptions({ debug: false })
87
+ ```
56
88
 
57
89
  ### `DownloadOptions`
58
90
 
59
91
  ```typescript
60
92
  interface DownloadOptions {
61
- headless?: boolean // Run browser headless (default: true)
62
- debug?: boolean // Enable debug logging (default: false)
63
- userAgent?: string // Custom user agent string
64
- timeout?: number // Operation timeout in ms (default: 100000)
93
+ headless?: boolean // default: true
94
+ debug?: boolean // default: false
95
+ userAgent?: string // custom UA (default: Chrome on Windows)
96
+ timeout?: number // navigation & download timeout (ms) default: 60000
97
+ downloadButtonTimeout?: number // wait for button timeout – default: 30000
98
+ retries?: number // total attempts – default: 3
99
+ retryDelay?: number // base delay before exponential backoff – default: 1000
100
+ onProgress?: (
101
+ percent: number,
102
+ total: 100,
103
+ meta: { stage: string; message: string; attempt?: number },
104
+ ) => void
105
+ correlationId?: string // for tracing across logs
106
+ saveDebugArtifacts?: boolean // save screenshot/html on error – default: true
107
+ logFile?: string // write structured logs to file
65
108
  }
66
109
  ```
67
110
 
@@ -69,9 +112,12 @@ interface DownloadOptions {
69
112
 
70
113
  ```typescript
71
114
  interface DownloadResult {
72
- filePath: string // Full path to saved file
73
- size: number // File size in bytes
74
- method: 'direct' | 'fallback' // Download strategy used
115
+ filePath: string // absolute path to saved file
116
+ size: number // bytes
117
+ method: 'direct' | 'fallback'
118
+ correlationId?: string
119
+ durationMs?: number
120
+ attempts?: number
75
121
  }
76
122
  ```
77
123
 
@@ -79,89 +125,149 @@ interface DownloadResult {
79
125
 
80
126
  ## Error Handling
81
127
 
128
+ All errors extend `AppError` and include:
129
+
130
+ - `code` – unique string identifier
131
+ - `retryable` – `true` for network/browser issues, `false` for validation/file errors
132
+ - `context` – frozen object with debugging info
133
+ - `timestamp` – ISO string
134
+ - `toJSON()` – serialisable for logging
135
+
82
136
  ```typescript
83
- import { downloadSfile, ValidationError, NetworkError } from 'sfiledl'
137
+ import { downloadSfile, isRetryableError, NetworkError } from 'sfiledl'
84
138
 
85
139
  try {
86
- await downloadSfile('https://sfile.co/file/xyz', './out')
140
+ await downloadSfile(url, './out')
87
141
  } catch (err) {
88
- if (err instanceof ValidationError) {
89
- console.error('Invalid input:', err.message)
142
+ if (isRetryableError(err)) {
143
+ console.log('Will be retried automatically by the library')
90
144
  }
91
- if (err instanceof NetworkError && err.retryable) {
92
- console.log('Network issue, retry possible')
145
+ if (err instanceof NetworkError) {
146
+ console.error('Network issue:', err.context)
93
147
  }
94
- // All errors include: code, timestamp, context, retryable flag
148
+ // All errors have .code, .retryable, .context
95
149
  }
96
150
  ```
97
151
 
98
- ### Error Types
152
+ ### Error types
153
+
154
+ | Class | Code | Retryable | When |
155
+ | ----------------- | ------------------ | --------- | -------------------------------------------------------------- |
156
+ | `ValidationError` | `VALIDATION_ERROR` | `false` | Invalid URL, save directory, or options |
157
+ | `NetworkError` | `NETWORK_ERROR` | `true` | Navigation failures, missing download button, request timeouts |
158
+ | `BrowserError` | `BROWSER_ERROR` | `true` | Playwright launch or page initialisation errors |
159
+ | `FileError` | `FILE_ERROR` | `false` | Filesystem write errors, missing permissions |
99
160
 
100
- | Error | Code | Retryable | When |
101
- | ----------------- | ------------------ | --------- | -------------------------- |
102
- | `ValidationError` | `VALIDATION_ERROR` | | Invalid URL or input |
103
- | `NetworkError` | `NETWORK_ERROR` | | Navigation/fetch failures |
104
- | `FileError` | `FILE_ERROR` | | File system issues |
105
- | `BrowserError` | `BROWSER_ERROR` | | Playwright launch failures |
161
+ ---
162
+
163
+ ## Debug Mode & Artifacts
164
+
165
+ Set `debug: true` in options to enable:
166
+
167
+ - Detailed console logging (including Playwright console/request failures)
168
+ - Automatic debug artifacts when an error occurs (saved to `/tmp/sfile_debug_<timestamp>/`):
169
+ - `error.png` – full page screenshot
170
+ - `error.html` – page source at failure
171
+ - `error.txt` – error message and stack
172
+ - `stages.json` – timeline of internal steps (launch, navigation, button wait, etc.)
173
+
174
+ ```typescript
175
+ await downloadSfile(url, './out', { debug: true, saveDebugArtifacts: true })
176
+ ```
106
177
 
107
178
  ---
108
179
 
109
- ## Debug Mode
180
+ ## Logging & Correlation
181
+
182
+ The library exports its own `Logger` class. You can create a logger with a correlation ID that will be automatically attached to every log line.
183
+
184
+ ```typescript
185
+ import { Logger } from 'sfiledl'
186
+
187
+ const logger = new Logger({
188
+ debugMode: true,
189
+ correlationId: 'my-session-123',
190
+ logFile: './app.log',
191
+ prefix: 'downloader',
192
+ })
193
+ logger.info('Starting download')
194
+ ```
195
+
196
+ The main download function also accepts a `correlationId` in `DownloadOptions`. That ID is used for all internal log messages and attached to the final `DownloadResult`.
197
+
198
+ ---
110
199
 
111
- Enable `debug: true` for verbose logging:
200
+ ## Progress Tracking
112
201
 
113
202
  ```typescript
114
- await downloadSfile(url, './out', { debug: true })
203
+ await downloadSfile(url, './out', {
204
+ onProgress: (percent, total, meta) => {
205
+ console.log(`${meta.stage}: ${meta.message} – ${percent}%`)
206
+ if (meta.attempt) console.log(`Retry attempt ${meta.attempt}`)
207
+ },
208
+ })
115
209
  ```
116
210
 
117
- On error, debug artifacts are auto-saved to `/tmp/sfile_debug_<timestamp>/`:
211
+ Stages emitted:
118
212
 
119
- - `error.png` Full page screenshot
120
- - `error.html` Page source at failure
121
- - `error.txt` Error message
213
+ - `launch` (10%) browser launching
214
+ - `navigation` (30%) page loaded
215
+ - `button` (50%) download button ready
216
+ - `trigger` (70%) – download triggered
217
+ - `complete` (100%) – file saved
218
+ - `retry` (0%) – before a retry
122
219
 
123
220
  ---
124
221
 
125
222
  ## Development
126
223
 
127
224
  ```bash
128
- # Clone & install
129
225
  git clone https://github.com/neuxdotdev/sfiledl.git
130
226
  cd sfiledl
131
227
  bun install
132
228
  bunx playwright install chromium
133
- # Rebuild (clean + lint + build + format)
229
+
230
+ # Full rebuild (clean, typecheck, build, format)
134
231
  bun run rebuild
135
232
 
136
- # Run tests
233
+ # Run tests (if available)
137
234
  bun run test
138
235
  ```
139
236
 
237
+ ### Scripts
238
+
239
+ | Command | Description |
240
+ | ---------------------- | ------------------------------ |
241
+ | `bun run clean` | Remove `build/` and cache |
242
+ | `bun run typecheck` | Run `tsc --noEmit` |
243
+ | `bun run build:ts` | Compile TypeScript to `build/` |
244
+ | `bun run build:bundle` | Bundle with Rollup |
245
+ | `bun run rebuild` | Full rebuild pipeline |
246
+ | `bun run format` | Format all files with Prettier |
247
+
140
248
  ---
141
249
 
142
250
  ## Contributing
143
251
 
144
252
  1. Fork the repository
145
253
  2. Create a feature branch (`git checkout -b feat/your-feature`)
146
- 3. Commit changes (`git commit -m 'feat: add your feature'`)
147
- 4. Push to branch (`git push origin feat/your-feature`)
148
- 5. Open a Pull Request
254
+ 3. Commit changes using [Conventional Commits](https://www.conventionalcommits.org/)
255
+ 4. Push and open a Pull Request
149
256
 
150
257
  ---
151
258
 
152
259
  ## License
153
260
 
154
- **AGPL-3.0-only** See [LICENSE](license) for details.
155
-
156
- > This license ensures that any network-distributed modifications remain open source.
261
+ **AGPL-3.0-only** see [LICENSE](license) for details.
262
+ This license ensures that any network‑distributed modifications remain open source.
157
263
 
158
264
  ---
159
265
 
160
266
  ## Credits
161
267
 
162
- - Built with [Playwright](https://playwright.dev) for reliable automation
163
- - Optimized for [Bun](https://bun.sh) runtime performance
164
- - Inspired by the need for simple, scriptable file downloads
268
+ - Built with [Playwright](https://playwright.dev) for reliable browser automation
269
+ - Optimised for [Bun](https://bun.sh) runtime performance
270
+ - Inspired by the need for simple, scriptable file downloads from sfile.co
165
271
 
166
272
  ---
167
273