mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
fix: add Object.hasOwn polyfill for old iOS/Android WebViews
@telegram-apps/sdk v3 depends on valibot which uses Object.hasOwn. On Safari < 15.4 and old Android WebViews this method is missing, causing LaunchParamsRetrieveError and broken initData auth. Ref: https://github.com/Telegram-Mini-Apps/tma.js/issues/683
This commit is contained in:
10
src/main.tsx
10
src/main.tsx
@@ -27,6 +27,16 @@ import { getCachedFullscreenEnabled, isTelegramMobile } from './hooks/useTelegra
|
|||||||
import './i18n';
|
import './i18n';
|
||||||
import './styles/globals.css';
|
import './styles/globals.css';
|
||||||
|
|
||||||
|
// Polyfill Object.hasOwn for older iOS/Android WebViews (Safari < 15.4, old Chrome).
|
||||||
|
// @telegram-apps/sdk v3 depends on valibot which uses Object.hasOwn internally.
|
||||||
|
// Without this, init() throws LaunchParamsRetrieveError on affected devices.
|
||||||
|
// See: https://github.com/Telegram-Mini-Apps/tma.js/issues/683
|
||||||
|
if (typeof (Object as { hasOwn?: unknown }).hasOwn !== 'function') {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
(Object as any).hasOwn = (obj: object, prop: PropertyKey): boolean =>
|
||||||
|
Object.prototype.hasOwnProperty.call(obj, prop);
|
||||||
|
}
|
||||||
|
|
||||||
// Only initialize Telegram SDK when running inside Telegram
|
// Only initialize Telegram SDK when running inside Telegram
|
||||||
const isTelegramEnv =
|
const isTelegramEnv =
|
||||||
!!(window as unknown as Record<string, unknown>).TelegramWebviewProxy ||
|
!!(window as unknown as Record<string, unknown>).TelegramWebviewProxy ||
|
||||||
|
|||||||
Reference in New Issue
Block a user