Commit 0ad0e4ce authored by nanahira's avatar nanahira

hanatan is back

parent cffb3dbb
......@@ -133,6 +133,7 @@ type ConversationJSONBody = {
* The parent message ID
*/
parent_message_id: string;
arkose_token?: string;
};
type Prompt = {
/**
......
......@@ -1272,6 +1272,7 @@ async function waitForRecaptcha(page, opts = {}) {
}
// src/chatgpt-api-browser.ts
import { getToken } from "funcaptcha";
var CHAT_PAGE_URL = "https://chat.openai.com/chat";
var ChatGPTAPIBrowser = class extends AChatGPTAPI {
constructor(opts) {
......@@ -1609,11 +1610,20 @@ var ChatGPTAPIBrowser = class extends AChatGPTAPI {
}
}
try {
const arkoseThing = await getToken({
pkey: "3D86FBBA-9D22-402A-B512-3420086BA6CC",
surl: "https://tcr9i.chat.openai.com",
headers: {
"User-Agent": await this._page.browser().userAgent()
},
site: "https://chat.openai.com",
proxy: this._proxyServer && (this._proxyServer.startsWith("http") ? this._proxyServer : `http://${this._proxyServer}`)
});
result = await this._page.evaluate(
browserPostEventStream,
url2,
this._accessToken,
body,
{ ...body, arkose_token: arkoseThing.token },
timeoutMs
);
} catch (err) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -14,6 +14,9 @@ dependencies:
expiry-map:
specifier: ^2.0.0
version: 2.0.0
funcaptcha:
specifier: ^1.1.5
version: 1.1.5
html-to-md:
specifier: ^0.8.3
version: 0.8.3
......@@ -388,6 +391,11 @@ packages:
dev: true
optional: true
/@fastify/busboy@2.0.0:
resolution: {integrity: sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==}
engines: {node: '>=14'}
dev: false
/@fisch0920/puppeteer-extra-plugin-recaptcha@3.6.6(puppeteer-extra@3.3.4):
resolution: {integrity: sha512-KI12BbqOupDm8+R21IS645L9/SzdYMVvMFdvGy2zIePJ5qPYNcqUIqBSA86hdk0vM2WJ1G5q1t7AUQoemGwbeQ==}
engines: {node: '>=9.11.2'}
......@@ -1745,6 +1753,12 @@ packages:
dev: true
optional: true
/funcaptcha@1.1.5:
resolution: {integrity: sha512-Ugyb17/Sq1ljiBn98Mtdf1aCVin0Xykp4Sr1O0S96YE/d/uAM5IiPrkDs3WBNNCMraJgQAPHkjf8hHvEXTQfJg==}
dependencies:
undici: 5.26.5
dev: false
/function-bind@1.1.1:
resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
dev: true
......@@ -4088,6 +4102,13 @@ packages:
buffer: 5.7.1
through: 2.3.8
/undici@5.26.5:
resolution: {integrity: sha512-cSb4bPFd5qgR7qr2jYAi0hlX9n5YKK2ONKkLFkxl+v/9BvC0sOpZjBHDBSXc5lWAf5ty9oZdRXytBIHzgUcerw==}
engines: {node: '>=14.0'}
dependencies:
'@fastify/busboy': 2.0.0
dev: false
/unified@10.1.2:
resolution: {integrity: sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==}
dependencies:
......
import delay from 'delay'
import { getToken } from 'funcaptcha'
import type { Browser, HTTPRequest, HTTPResponse, Page } from 'puppeteer'
import { temporaryDirectory } from 'tempy'
import { v4 as uuidv4 } from 'uuid'
......@@ -515,12 +516,26 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
}
try {
const arkoseThing = await getToken({
pkey: '3D86FBBA-9D22-402A-B512-3420086BA6CC',
surl: 'https://tcr9i.chat.openai.com',
headers: {
'User-Agent': await this._page.browser().userAgent()
},
site: 'https://chat.openai.com',
proxy:
this._proxyServer &&
(this._proxyServer.startsWith('http')
? this._proxyServer
: `http://${this._proxyServer}`)
})
// console.log('>>> EVALUATE', url, this._accessToken, body)
result = await this._page.evaluate(
browserPostEventStream,
url,
this._accessToken,
body,
{ ...body, arkose_token: arkoseThing.token },
timeoutMs
)
} catch (err) {
......
......@@ -156,6 +156,8 @@ export type ConversationJSONBody = {
* The parent message ID
*/
parent_message_id: string
arkose_token?: string
}
export type Prompt = {
......
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