@anonympins/fingerprint 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +494 -493
- package/fingerprint.client.js +19 -8
- package/fingerprint.js +394 -144
- package/library.js +1577 -1577
- package/package.json +76 -75
- package/pow.solver.js +214 -0
package/fingerprint.client.js
CHANGED
|
@@ -238,7 +238,9 @@ const ClientLibrary = {
|
|
|
238
238
|
|
|
239
239
|
_isFetchPatched: false,
|
|
240
240
|
_interceptorChain: [],
|
|
241
|
-
|
|
241
|
+
// On "lie" (bind) la fonction fetch à son contexte d'origine (window) pour éviter les erreurs "Illegal invocation".
|
|
242
|
+
// C'est la correction clé pour le problème que vous rencontrez.
|
|
243
|
+
_originalFetch: (typeof window !== 'undefined') ? window.fetch.bind(window) : () => Promise.reject(new Error('fetch is not available')),
|
|
242
244
|
|
|
243
245
|
/**
|
|
244
246
|
* Adds an interceptor function to the `fetch` chain.
|
|
@@ -330,10 +332,10 @@ const ClientLibrary = {
|
|
|
330
332
|
* @private
|
|
331
333
|
*/
|
|
332
334
|
async solveChallengeAndRetry(response, resource, options) {
|
|
333
|
-
if (response.status !==
|
|
335
|
+
if (response.status !== 404 || !response.headers.get('content-type')?.includes('application/json')) {
|
|
334
336
|
return response;
|
|
335
337
|
}
|
|
336
|
-
|
|
338
|
+
|
|
337
339
|
try {
|
|
338
340
|
const challengeData = await response.json();
|
|
339
341
|
if (!challengeData.challenge || !challengeData.challenge.type) {
|
|
@@ -346,14 +348,23 @@ const ClientLibrary = {
|
|
|
346
348
|
|
|
347
349
|
// Ajouter la solution aux paramètres de la requête pour le nouvel essai
|
|
348
350
|
const url = new URL((resource instanceof Request) ? resource.url : String(resource), window.location.origin);
|
|
349
|
-
|
|
351
|
+
// Le type de challenge est maintenant `cpu_mem` pour les API
|
|
352
|
+
url.searchParams.set('pow_type', 'cpu_mem');
|
|
350
353
|
url.searchParams.set('pow_nonce', challengeData.challenge.nonce);
|
|
354
|
+
|
|
351
355
|
// La solution peut être un objet (pour les challenges combinés) ou une valeur simple
|
|
352
356
|
Object.entries(solution).forEach(([key, value]) => {
|
|
353
|
-
|
|
357
|
+
// Le serveur attend pow_solution_cpu et pow_solution_mem
|
|
358
|
+
// On s'assure que la clé est bien 'cpu' ou 'mem' avant de l'ajouter
|
|
359
|
+
if (key === 'cpu' || key === 'mem') {
|
|
360
|
+
url.searchParams.set(`pow_solution_${key}`, String(value));
|
|
361
|
+
}
|
|
354
362
|
});
|
|
355
363
|
|
|
356
|
-
|
|
364
|
+
// On utilise la chaîne d'intercepteurs pour la requête réessayée,
|
|
365
|
+
// ce qui garantit que le fetch original est appelé avec le bon contexte.
|
|
366
|
+
// Cela évite de réintroduire l'erreur "Illegal invocation".
|
|
367
|
+
return window.fetch(url.toString(), options);
|
|
357
368
|
} catch (e) {
|
|
358
369
|
console.error('[Fingerprint] Failed to solve or retry challenge:', e);
|
|
359
370
|
return response; // Retourne la réponse 429 originale en cas d'échec
|
|
@@ -390,8 +401,8 @@ const ClientLibrary = {
|
|
|
390
401
|
if (honeypots.length > 0) {
|
|
391
402
|
this.initializeHoneypots(honeypots);
|
|
392
403
|
}
|
|
393
|
-
// On
|
|
394
|
-
if (
|
|
404
|
+
// On active l'interception si `fetch` est configuré, même avec un objet vide.
|
|
405
|
+
if (config.fetch) {
|
|
395
406
|
this.initializeFetch(fetchConfig.targetDomains);
|
|
396
407
|
|
|
397
408
|
// Ajoute l'intercepteur pour la résolution de challenge
|