fix: resolve telegram auth token expiration and clean up codebase

- Fix stale initData comparison in clearStaleSessionIfNeeded that destroyed
  valid refresh tokens on mobile WebView reopens
- Restrict X-Telegram-Init-Data header to auth endpoints only
- Close Mini App on auth retry to force fresh initData from Telegram
- Merge Connection page error/not-configured states for better UX
- Remove unnecessary comments across 40+ files (section dividers,
  restating comments, noise catch block comments)
- Configure ESLint allowEmptyCatch to properly handle intentional
  empty catch blocks (62 warnings resolved)
This commit is contained in:
c0mrade
2026-03-13 17:50:49 +03:00
parent 682b6b70dc
commit 2dab25c5a0
43 changed files with 72 additions and 647 deletions

View File

@@ -38,40 +38,29 @@ if (!alreadyInitialized) {
init();
restoreInitData();
// Сбрасываем старые токены если init data изменился (новая сессия Telegram)
clearStaleSessionIfNeeded(retrieveRawInitData() || null);
// Mount components — each in its own try/catch so one failure doesn't block others
// Note: mountMiniApp() internally mounts themeParams in SDK v3,
// so we don't call mountThemeParams() separately to avoid ConcurrentCallError
// Each mount in its own try/catch so one failure doesn't block others.
// mountMiniApp() internally mounts themeParams in SDK v3,
// so we don't call mountThemeParams() separately to avoid ConcurrentCallError.
try {
mountMiniApp();
} catch {
/* already mounted */
}
} catch {}
try {
bindThemeParamsCssVars();
} catch {
/* theme params not yet available */
}
} catch {}
try {
mountSwipeBehavior();
disableVerticalSwipes();
} catch {
/* already mounted */
}
} catch {}
try {
mountClosingBehavior();
disableClosingConfirmation();
} catch {
/* already mounted */
}
} catch {}
try {
mountBackButton();
} catch {
/* already mounted */
}
// Viewport — async, fullscreen зависит от смонтированного viewport
} catch {}
// Viewport must be mounted before requesting fullscreen
mountViewport()
.then(() => {
bindViewportCssVars();
@@ -87,12 +76,9 @@ if (!alreadyInitialized) {
.catch(() => {});
miniAppReady();
} catch {
// Not in Telegram — ok
}
} catch {}
}
// Preload logo from cache — defer to idle time so it doesn't compete with LCP
if ('requestIdleCallback' in window) {
requestIdleCallback(() => initLogoPreload());
} else {