17.05.2026 funny
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { getCsrfToken } from '@shared/api/csrf'
|
||||
import { tokenStore } from '@shared/api/tokenStore'
|
||||
|
||||
const USERS_API_URL = 'https://app.users.elcsa.ru'
|
||||
|
||||
@@ -9,26 +10,58 @@ export interface MeResponse {
|
||||
middle_name: string
|
||||
last_name: string
|
||||
birth_date: string
|
||||
crypto_wallet: string | null
|
||||
encrypted_mnemonic: string | null
|
||||
phone: string
|
||||
passport_data: string | null
|
||||
inn: string | null
|
||||
erc20: string | null
|
||||
avatar_link: string | null
|
||||
kyc_verified: boolean
|
||||
is_deleted: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
kyc_verified_at: string | null
|
||||
webp_size_bytes: number
|
||||
}
|
||||
|
||||
export interface UploadAvatarPayload {
|
||||
photo_base64: string
|
||||
decoded_bytes: string
|
||||
}
|
||||
|
||||
async function authedHeaders(): Promise<HeadersInit> {
|
||||
const csrf = await getCsrfToken()
|
||||
const bearer = tokenStore.get()
|
||||
return {
|
||||
'X-CSRF-Token': csrf,
|
||||
...(bearer ? { Authorization: `Bearer ${bearer}` } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
export async function getMe(): Promise<MeResponse> {
|
||||
const csrf = await getCsrfToken()
|
||||
const headers = await authedHeaders()
|
||||
|
||||
const res = await fetch(`${USERS_API_URL}/me/`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'X-CSRF-Token': csrf,
|
||||
},
|
||||
headers,
|
||||
})
|
||||
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw data
|
||||
return data
|
||||
}
|
||||
|
||||
export async function uploadAvatar(payload: UploadAvatarPayload): Promise<MeResponse> {
|
||||
const headers = await authedHeaders()
|
||||
|
||||
const res = await fetch(`${USERS_API_URL}/me/settings/avatar`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...headers,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
const data = await res.json()
|
||||
|
||||
Reference in New Issue
Block a user