Commit d685b780 authored by Travis Fischer's avatar Travis Fischer

fix: minor cleanups of executablePath

parent 94d54836
......@@ -3,11 +3,7 @@ import type { Browser, HTTPRequest, HTTPResponse, Page } from 'puppeteer'
import { v4 as uuidv4 } from 'uuid'
import * as types from './types'
import {
defaultChromeExecutablePath,
getBrowser,
getOpenAIAuth
} from './openai-auth'
import { getBrowser, getOpenAIAuth } from './openai-auth'
import {
browserPostEventStream,
isRelevantRequest,
......@@ -63,7 +59,7 @@ export class ChatGPTAPIBrowser {
isGoogleLogin = false,
minimize = true,
captchaToken,
browserPath = defaultChromeExecutablePath()
browserPath
} = opts
this._email = email
......@@ -95,6 +91,8 @@ export class ChatGPTAPIBrowser {
this._page.on('request', this._onRequest.bind(this))
this._page.on('response', this._onResponse.bind(this))
maximizePage(this._page)
// bypass cloudflare and login
await getOpenAIAuth({
email: this._email,
......
......@@ -46,7 +46,8 @@ export async function getOpenAIAuth({
page,
timeoutMs = 2 * 60 * 1000,
isGoogleLogin = false,
captchaToken = process.env.CAPTCHA_TOKEN
captchaToken = process.env.CAPTCHA_TOKEN,
executablePath
}: {
email?: string
password?: string
......@@ -55,13 +56,14 @@ export async function getOpenAIAuth({
timeoutMs?: number
isGoogleLogin?: boolean
captchaToken?: string
executablePath?: string
}): Promise<OpenAIAuth> {
const origBrowser = browser
const origPage = page
try {
if (!browser) {
browser = await getBrowser({ captchaToken })
browser = await getBrowser({ captchaToken, executablePath })
}
const userAgent = await browser.userAgent()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment