mirror of
https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
synced 2026-04-22 01:57:56 +00:00
debug: add retry auth button and increase wait time to 5s
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pezkuwi-telegram-miniapp",
|
||||
"version": "1.0.148",
|
||||
"version": "1.0.149",
|
||||
"type": "module",
|
||||
"description": "Pezkuwichain Telegram Mini App - Forum, Announcements, Rewards",
|
||||
"author": "Pezkuwichain Team",
|
||||
|
||||
@@ -22,7 +22,8 @@ interface AuthContextType {
|
||||
const AuthContext = createContext<AuthContextType | null>(null);
|
||||
|
||||
// Wait for Telegram SDK to be ready with initData
|
||||
function waitForInitData(maxAttempts = 10, intervalMs = 200): Promise<string | null> {
|
||||
// 25 attempts * 200ms = 5 seconds max wait
|
||||
function waitForInitData(maxAttempts = 25, intervalMs = 200): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
let attempts = 0;
|
||||
|
||||
|
||||
@@ -14,7 +14,14 @@ import { useAuth } from '@/contexts/AuthContext';
|
||||
|
||||
export function AnnouncementsSection() {
|
||||
const { hapticImpact, hapticNotification, openLink } = useTelegram();
|
||||
const { isAuthenticated, sessionToken, user, authError } = useAuth();
|
||||
const {
|
||||
isAuthenticated,
|
||||
sessionToken,
|
||||
user,
|
||||
authError,
|
||||
signIn,
|
||||
isLoading: authLoading,
|
||||
} = useAuth();
|
||||
|
||||
const { data: announcements, isLoading, refetch, isRefetching } = useAnnouncements();
|
||||
const reactionMutation = useAnnouncementReaction(sessionToken);
|
||||
@@ -91,6 +98,15 @@ export function AnnouncementsSection() {
|
||||
Platform: {window.Telegram?.WebApp?.platform || 'unknown'} | Ver:{' '}
|
||||
{window.Telegram?.WebApp?.version || '?'}
|
||||
</div>
|
||||
{!isAuthenticated && (
|
||||
<button
|
||||
onClick={() => signIn()}
|
||||
disabled={authLoading}
|
||||
className="mt-2 px-3 py-1 bg-yellow-500 text-black rounded text-xs font-medium"
|
||||
>
|
||||
{authLoading ? 'Deneniyor...' : 'Retry Auth'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.148",
|
||||
"buildTime": "2026-02-07T02:35:20.304Z",
|
||||
"buildNumber": 1770431720305
|
||||
"version": "1.0.149",
|
||||
"buildTime": "2026-02-07T02:40:20.478Z",
|
||||
"buildNumber": 1770432020479
|
||||
}
|
||||
|
||||
@@ -139,20 +139,33 @@ function verifySessionToken(token: string, botToken: string): number | null {
|
||||
}
|
||||
|
||||
serve(async (req) => {
|
||||
console.log('[telegram-auth] Request received:', req.method);
|
||||
const method = req.method;
|
||||
const origin = req.headers.get('origin');
|
||||
console.log('[telegram-auth] ===== REQUEST =====');
|
||||
console.log('[telegram-auth] Method:', method, '| Origin:', origin);
|
||||
|
||||
const corsHeaders = getCorsHeaders(req.headers.get('origin'));
|
||||
const corsHeaders = getCorsHeaders(origin);
|
||||
|
||||
// Handle CORS preflight
|
||||
if (req.method === 'OPTIONS') {
|
||||
console.log('[telegram-auth] CORS preflight');
|
||||
if (method === 'OPTIONS') {
|
||||
console.log('[telegram-auth] CORS preflight - returning OK');
|
||||
return new Response('ok', { headers: corsHeaders });
|
||||
}
|
||||
|
||||
console.log('[telegram-auth] Processing POST request...');
|
||||
|
||||
try {
|
||||
console.log('[telegram-auth] Parsing body...');
|
||||
console.log('[telegram-auth] Parsing JSON body...');
|
||||
const body = await req.json();
|
||||
console.log('[telegram-auth] Body parsed, initData:', body.initData ? 'exists' : 'missing');
|
||||
const hasInitData = !!body.initData;
|
||||
const hasSessionToken = !!body.sessionToken;
|
||||
console.log(
|
||||
'[telegram-auth] Body parsed - initData:',
|
||||
hasInitData,
|
||||
'| sessionToken:',
|
||||
hasSessionToken
|
||||
);
|
||||
|
||||
const { initData, sessionToken } = body;
|
||||
|
||||
// Get environment variables
|
||||
|
||||
Reference in New Issue
Block a user