Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Chatgpt Puppeteer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Chatgpt Puppeteer
Commits
39dc4de3
Commit
39dc4de3
authored
Dec 18, 2022
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: fix linting issues
parent
b936a04b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
src/openai-auth.ts
src/openai-auth.ts
+15
-8
No files found.
src/openai-auth.ts
View file @
39dc4de3
...
@@ -56,7 +56,7 @@ export async function getOpenAIAuth({
...
@@ -56,7 +56,7 @@ export async function getOpenAIAuth({
captchaToken
=
process
.
env
.
CAPTCHA_TOKEN
,
captchaToken
=
process
.
env
.
CAPTCHA_TOKEN
,
nopechaKey
=
process
.
env
.
NOPECHA_KEY
,
nopechaKey
=
process
.
env
.
NOPECHA_KEY
,
executablePath
,
executablePath
,
proxyServer
=
process
.
env
.
PROXY_SERVER
,
proxyServer
=
process
.
env
.
PROXY_SERVER
}:
{
}:
{
email
?:
string
email
?:
string
password
?:
string
password
?:
string
...
@@ -66,7 +66,7 @@ export async function getOpenAIAuth({
...
@@ -66,7 +66,7 @@ export async function getOpenAIAuth({
isGoogleLogin
?:
boolean
isGoogleLogin
?:
boolean
captchaToken
?:
string
captchaToken
?:
string
nopechaKey
?:
string
nopechaKey
?:
string
executablePath
?:
string
,
executablePath
?:
string
proxyServer
?:
string
proxyServer
?:
string
}):
Promise
<
OpenAIAuth
>
{
}):
Promise
<
OpenAIAuth
>
{
const
origBrowser
=
browser
const
origBrowser
=
browser
...
@@ -74,7 +74,12 @@ export async function getOpenAIAuth({
...
@@ -74,7 +74,12 @@ export async function getOpenAIAuth({
try
{
try
{
if
(
!
browser
)
{
if
(
!
browser
)
{
browser
=
await
getBrowser
({
captchaToken
,
nopechaKey
,
executablePath
,
proxyServer
})
browser
=
await
getBrowser
({
captchaToken
,
nopechaKey
,
executablePath
,
proxyServer
})
}
}
const
userAgent
=
await
browser
.
userAgent
()
const
userAgent
=
await
browser
.
userAgent
()
...
@@ -299,20 +304,22 @@ export async function getBrowser(
...
@@ -299,20 +304,22 @@ export async function getBrowser(
if
(
process
.
env
.
PROXY_VALIDATE_IP
)
{
if
(
process
.
env
.
PROXY_VALIDATE_IP
)
{
const
page
=
(
await
browser
.
pages
())[
0
]
||
(
await
browser
.
newPage
())
const
page
=
(
await
browser
.
pages
())[
0
]
||
(
await
browser
.
newPage
())
// send a fetch request to https://ifconfig.co using page.evaluate() and verify the IP matches
// send a fetch request to https://ifconfig.co using page.evaluate() and verify the IP matches
let
ip
;
let
ip
try
{
try
{
({
ip
}
=
await
page
.
evaluate
(()
=>
{
;
({
ip
}
=
await
page
.
evaluate
(()
=>
{
return
fetch
(
'
https://ifconfig.co
'
,
{
return
fetch
(
'
https://ifconfig.co
'
,
{
headers
:
{
headers
:
{
'
Accept
'
:
'
application/json
'
Accept
:
'
application/json
'
}
}
}).
then
((
res
)
=>
res
.
json
())
}).
then
((
res
)
=>
res
.
json
())
}))
;
}))
}
catch
(
err
)
{
}
catch
(
err
)
{
throw
new
Error
(
`Proxy IP validation failed:
${
err
.
message
}
`
)
throw
new
Error
(
`Proxy IP validation failed:
${
err
.
message
}
`
)
}
}
if
(
ip
!==
process
.
env
.
PROXY_VALIDATE_IP
)
{
if
(
ip
!==
process
.
env
.
PROXY_VALIDATE_IP
)
{
throw
new
Error
(
`Proxy IP mismatch:
${
ip
}
!==
${
process
.
env
.
PROXY_VALIDATE_IP
}
`
)
throw
new
Error
(
`Proxy IP mismatch:
${
ip
}
!==
${
process
.
env
.
PROXY_VALIDATE_IP
}
`
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment