Skip to content

Commit

Permalink
upgrade chatgpt web (new arkoseToken and requirementsToken) (#653, #658
Browse files Browse the repository at this point in the history
…, #661)
  • Loading branch information
josStorer committed Mar 23, 2024
1 parent 68e3a8a commit 074b6cc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/services/apis/chatgpt-web.mjs
Expand Up @@ -49,6 +49,15 @@ export async function getModels(token) {
if (response.models) return response.models.map((m) => m.slug)
}

export async function getRequirementsToken(accessToken) {
const response = JSON.parse(
(await request(accessToken, 'POST', '/sentinel/chat-requirements')).responseText,
)
if (response.token) {
return response.token
}
}

/**
* @param {Runtime.Port} port
* @param {string} question
Expand All @@ -74,6 +83,7 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
)

const models = await getModels(accessToken).catch(cleanController)
const requirementsToken = await getRequirementsToken(accessToken)
console.debug('models', models)
const config = await getUserConfig()
const selectedModel = Models[session.modelName].value
Expand Down Expand Up @@ -132,6 +142,8 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
...(cookie && { Cookie: cookie }),
'Openai-Sentinel-Arkose-Token': arkoseToken || '',
'Openai-Sentinel-Chat-Requirements-Token': requirementsToken || '',
},
body: JSON.stringify({
action: 'next',
Expand All @@ -158,7 +170,6 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
parent_message_id: session.parentMessageId,
timezone_offset_min: new Date().getTimezoneOffset(),
history_and_training_disabled: config.disableWebModeHistory,
arkose_token: arkoseToken,
}),
}
await fetchSSE(url, {
Expand Down

0 comments on commit 074b6cc

Please sign in to comment.