Update community IDs, enhance CaptchaController caching, and modify home template for Altcha integration

- Changed community IDs for various components in graph.json to reflect updated associations.
- Added Cache-Control headers to the challenge and config methods in CaptchaController to prevent caching by CDNs and proxies.
- Updated the Altcha widget in home.html.twig to include a language attribute for better localization.
- Added a new AST cache file for CaptchaController to improve performance.
- Updated manifest.json with new modification times and AST hashes for several files.
This commit is contained in:
hamed
2026-07-10 11:57:16 +03:30
parent ec184dfcc8
commit 3eee6c3886
11 changed files with 111 additions and 116 deletions
+10 -12
View File
@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import 'altcha';
import 'altcha/i18n/fa'; // ثبت locale رسمی فارسی → با language="fa" فعال می‌شود
// ALTCHA خودمیزبان: widget با گرفتن challenge از بک‌اند، proof-of-work را در
// پس‌زمینه‌ی مرورگر حل می‌کند و مقدار base64 حل‌شده را در event `verified` می‌دهد.
@@ -10,16 +11,6 @@ interface AltchaProps {
challengeUrl?: string;
}
// برچسب‌های فارسی widget (ترجمه‌ی رسمی locale fa).
const FA_STRINGS = JSON.stringify({
label: 'من ربات نیستم',
verifying: 'در حال بررسی...',
verified: 'تأیید شد',
waitAlert: 'در حال بررسی... لطفاً منتظر بمانید.',
error: 'احراز هویت ناموفق بود. کمی بعد دوباره تلاش کنید.',
expired: 'احراز هویت منقضی شد. دوباره تلاش کنید.',
});
// altcha-widget یک custom element است؛ به JSX معرفی می‌شود (React 19: namespace زیر React.JSX).
declare module 'react' {
namespace JSX {
@@ -50,7 +41,11 @@ export default function Altcha({ onVerified, challengeUrl = '/api/v1/altcha/chal
return () => { alive = false; };
}, [onVerified]);
// config (challengeurl/strings/auto) را با setAttribute ست می‌کنیم، نه JSX prop —
// React ممکن است پراپ custom element را به‌صورت property ست کند و widget آن را
// نخواند؛ نتیجه challengeurl خالی و fetch صفحه‌ی جاری (HTML) به‌جای JSON بود.
useEffect(() => {
if (enabled !== true) return;
const el = ref.current;
if (!el) return;
@@ -61,11 +56,14 @@ export default function Altcha({ onVerified, challengeUrl = '/api/v1/altcha/chal
}
};
el.setAttribute('challengeurl', challengeUrl);
el.setAttribute('language', 'fa');
el.setAttribute('auto', 'onload');
el.addEventListener('statechange', onStateChange);
return () => el.removeEventListener('statechange', onStateChange);
}, [onVerified, enabled]);
}, [onVerified, enabled, challengeUrl]);
if (enabled !== true) return null;
return <altcha-widget ref={ref as React.Ref<HTMLElement>} challengeurl={challengeUrl} strings={FA_STRINGS} />;
return <altcha-widget ref={ref as React.Ref<HTMLElement>} />;
}