mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat: add browser environment support with access token authentication
Enable the web client to run in plain browser environments alongside Telegram Mini App support: - Server: Add CLI_API_TOKEN authentication path as alternative to Telegram initData - Client: Add useAuthSource hook to detect and manage Telegram vs browser auth sources - Client: Add usePlatform hook for platform abstraction with graceful haptic feedback degradation - Client: Add LoginPrompt component for browser access token login - Client: Extend useTheme to fall back to system prefers-color-scheme in browser - Client: Migrate all direct HapticFeedback calls to use usePlatform hook
This commit is contained in:
@@ -34,11 +34,11 @@ export class ApiClient {
|
||||
return await res.json() as T
|
||||
}
|
||||
|
||||
async authenticate(initData: string): Promise<AuthResponse> {
|
||||
async authenticate(auth: { initData: string } | { accessToken: string }): Promise<AuthResponse> {
|
||||
const res = await fetch('/api/auth', {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ initData })
|
||||
body: JSON.stringify(auth)
|
||||
})
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user