ngl idk what it did, might be big
Fetch and Save Remote Content / fetch (push) Failing after 12m58s

This commit is contained in:
aka paul
2026-06-03 18:21:26 +02:00
parent 7dd716c10c
commit 0e0682ffaf
+27 -14
View File
@@ -1,5 +1,6 @@
let cachedAuthKey = null; let cachedAuthKey = null;
let cachedAuthExpires = 0; let cachedAuthExpires = 0;
let authKeyPromise = null;
async function getFingerprint() { async function getFingerprint() {
let canvasVal = "zN12a8x9c7Vb5m4l3k2j1h"; let canvasVal = "zN12a8x9c7Vb5m4l3k2j1h";
@@ -60,22 +61,34 @@ async function getAuthKey() {
if (cachedAuthKey && Math.floor(Date.now() / 1000) < cachedAuthExpires) { if (cachedAuthKey && Math.floor(Date.now() / 1000) < cachedAuthExpires) {
return cachedAuthKey; return cachedAuthKey;
} }
const fp = await getFingerprint();
const sessionRes = await fetchv2(
'https://animeverse.to/api/v1/session',
{ 'content-type': 'application/json', 'user-agent': fp.ua },
'POST',
JSON.stringify({ fp })
);
const sessionText = typeof sessionRes.text === 'function' ? await sessionRes.text() : sessionRes; if (authKeyPromise) {
const sessionData = JSON.parse(sessionText); return authKeyPromise;
if (!sessionData.clientAuthKey) {
throw new Error("Session bootstrap failed: " + sessionText);
} }
cachedAuthKey = sessionData.clientAuthKey;
cachedAuthExpires = sessionData.expiresAt - 10; authKeyPromise = (async () => {
return cachedAuthKey; try {
const fp = await getFingerprint();
const sessionRes = await fetchv2(
'https://animeverse.to/api/v1/session',
{ 'content-type': 'application/json', 'user-agent': fp.ua },
'POST',
JSON.stringify({ fp })
);
const sessionText = typeof sessionRes.text === 'function' ? await sessionRes.text() : sessionRes;
const sessionData = JSON.parse(sessionText);
if (!sessionData.clientAuthKey) {
throw new Error("Session bootstrap failed: " + sessionText);
}
cachedAuthKey = sessionData.clientAuthKey;
cachedAuthExpires = sessionData.expiresAt - 10;
return cachedAuthKey;
} finally {
authKeyPromise = null;
}
})();
return authKeyPromise;
} }
async function fetchSigned(urlPath) { async function fetchSigned(urlPath) {