mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
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:
@@ -73,18 +73,14 @@ function createBackButtonController(): BackButtonController {
|
||||
if (currentCallback) {
|
||||
try {
|
||||
offBackButtonClick(currentCallback);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
currentCallback = onClick;
|
||||
try {
|
||||
onBackButtonClick(onClick);
|
||||
showBackButton();
|
||||
} catch {
|
||||
// Back button not mounted
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
|
||||
hide() {
|
||||
@@ -93,16 +89,12 @@ function createBackButtonController(): BackButtonController {
|
||||
if (currentCallback) {
|
||||
try {
|
||||
offBackButtonClick(currentCallback);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
} catch {}
|
||||
currentCallback = null;
|
||||
}
|
||||
try {
|
||||
hideBackButton();
|
||||
} catch {
|
||||
// Back button not mounted
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -115,27 +107,21 @@ function createHapticController(): HapticController {
|
||||
if (!inTelegram) return;
|
||||
try {
|
||||
hapticFeedbackImpactOccurred(style);
|
||||
} catch {
|
||||
// Haptic not available
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
|
||||
notification(type: HapticNotificationType) {
|
||||
if (!inTelegram) return;
|
||||
try {
|
||||
hapticFeedbackNotificationOccurred(type);
|
||||
} catch {
|
||||
// Haptic not available
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
|
||||
selection() {
|
||||
if (!inTelegram) return;
|
||||
try {
|
||||
hapticFeedbackSelectionChanged();
|
||||
} catch {
|
||||
// Haptic not available
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -183,8 +169,6 @@ function createDialogController(): DialogController {
|
||||
}
|
||||
try {
|
||||
const buttons = options.buttons?.map((btn) => {
|
||||
// For 'ok', 'close', 'cancel' types: do NOT include text
|
||||
// For 'default', 'destructive' types: text is required
|
||||
if (btn.type === 'ok' || btn.type === 'close' || btn.type === 'cancel') {
|
||||
return { type: btn.type, id: btn.id };
|
||||
}
|
||||
@@ -212,18 +196,14 @@ function createThemeController(): ThemeController {
|
||||
if (!inTelegram) return;
|
||||
try {
|
||||
setMiniAppHeaderColor(color as `#${string}`);
|
||||
} catch {
|
||||
// Not supported
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
|
||||
setBottomBarColor(color: string) {
|
||||
if (!inTelegram) return;
|
||||
try {
|
||||
setMiniAppBottomBarColor(color as `#${string}`);
|
||||
} catch {
|
||||
// Not supported
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
|
||||
getThemeParams() {
|
||||
@@ -231,7 +211,6 @@ function createThemeController(): ThemeController {
|
||||
try {
|
||||
const params = themeParamsState();
|
||||
if (!params) return null;
|
||||
// SDK v3 uses camelCase — convert to snake_case for our interface
|
||||
return {
|
||||
bg_color: params.bgColor,
|
||||
text_color: params.textColor,
|
||||
@@ -330,9 +309,7 @@ export function createTelegramAdapter(): PlatformContext {
|
||||
try {
|
||||
await navigator.share({ text: shareText, url });
|
||||
return true;
|
||||
} catch {
|
||||
// User cancelled or share failed
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -350,9 +327,7 @@ export function createTelegramAdapter(): PlatformContext {
|
||||
} else {
|
||||
disableClosingConfirmation();
|
||||
}
|
||||
} catch {
|
||||
// Not supported
|
||||
}
|
||||
} catch {}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import type {
|
||||
HapticNotificationType,
|
||||
} from '@/platform/types';
|
||||
|
||||
// Storage key for local storage fallback
|
||||
const STORAGE_PREFIX = 'bedolaga_';
|
||||
|
||||
function createCapabilities(): PlatformCapabilities {
|
||||
@@ -154,7 +153,6 @@ function createCloudStorageController(): CloudStorageController {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_PREFIX + key, value);
|
||||
} catch {
|
||||
// Storage might be full or disabled
|
||||
console.warn('Failed to save to localStorage:', key);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user