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' ...@@ -3,11 +3,7 @@ import type { Browser, HTTPRequest, HTTPResponse, Page } from 'puppeteer'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import * as types from './types' import * as types from './types'
import { import { getBrowser, getOpenAIAuth } from './openai-auth'
defaultChromeExecutablePath,
getBrowser,
getOpenAIAuth
} from './openai-auth'
import { import {
browserPostEventStream, browserPostEventStream,
isRelevantRequest, isRelevantRequest,
...@@ -63,7 +59,7 @@ export class ChatGPTAPIBrowser { ...@@ -63,7 +59,7 @@ export class ChatGPTAPIBrowser {
isGoogleLogin = false, isGoogleLogin = false,
minimize = true, minimize = true,
captchaToken, captchaToken,
browserPath = defaultChromeExecutablePath() browserPath
} = opts } = opts
this._email = email this._email = email
...@@ -95,6 +91,8 @@ export class ChatGPTAPIBrowser { ...@@ -95,6 +91,8 @@ export class ChatGPTAPIBrowser {
this._page.on('request', this._onRequest.bind(this)) this._page.on('request', this._onRequest.bind(this))
this._page.on('response', this._onResponse.bind(this)) this._page.on('response', this._onResponse.bind(this))
maximizePage(this._page)
// bypass cloudflare and login // bypass cloudflare and login
await getOpenAIAuth({ await getOpenAIAuth({
email: this._email, email: this._email,
......
...@@ -46,7 +46,8 @@ export async function getOpenAIAuth({ ...@@ -46,7 +46,8 @@ export async function getOpenAIAuth({
page, page,
timeoutMs = 2 * 60 * 1000, timeoutMs = 2 * 60 * 1000,
isGoogleLogin = false, isGoogleLogin = false,
captchaToken = process.env.CAPTCHA_TOKEN captchaToken = process.env.CAPTCHA_TOKEN,
executablePath
}: { }: {
email?: string email?: string
password?: string password?: string
...@@ -55,13 +56,14 @@ export async function getOpenAIAuth({ ...@@ -55,13 +56,14 @@ export async function getOpenAIAuth({
timeoutMs?: number timeoutMs?: number
isGoogleLogin?: boolean isGoogleLogin?: boolean
captchaToken?: string captchaToken?: string
executablePath?: string
}): Promise<OpenAIAuth> { }): Promise<OpenAIAuth> {
const origBrowser = browser const origBrowser = browser
const origPage = page const origPage = page
try { try {
if (!browser) { if (!browser) {
browser = await getBrowser({ captchaToken }) browser = await getBrowser({ captchaToken, executablePath })
} }
const userAgent = await browser.userAgent() 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