// =================== // © AngelaMos | 2026 // client.ts // =================== import { API_ENDPOINTS } from '@/config' import { apiClient } from '@/core/api' import type { CfgView, ChallengeDetail, ChallengeSummary, DisasmView, ElfView, HexView, ProgressView, StringsView, SubmitRequest, SubmitResult, Target, XrefsView, } from './types' export async function fetchChallenges(): Promise { const { data } = await apiClient.get( API_ENDPOINTS.CHALLENGES ) return data } export async function fetchChallenge(cid: string): Promise { const { data } = await apiClient.get( API_ENDPOINTS.CHALLENGE(cid) ) return data } export async function fetchHex( cid: string, offset: number, length: number ): Promise { const { data } = await apiClient.get(API_ENDPOINTS.HEX(cid), { params: { offset, length }, }) return data } export async function fetchElf(cid: string): Promise { const { data } = await apiClient.get(API_ENDPOINTS.ELF(cid)) return data } export async function fetchDisasm( cid: string, target: Target, session: string ): Promise { const { data } = await apiClient.get(API_ENDPOINTS.DISASM(cid), { params: { symbol: target.symbol, address: target.address, session }, }) return data } export async function fetchCfg(cid: string, target: Target): Promise { const { data } = await apiClient.get(API_ENDPOINTS.CFG(cid), { params: { symbol: target.symbol, address: target.address }, }) return data } export async function fetchXrefs( cid: string, target: number ): Promise { const { data } = await apiClient.get(API_ENDPOINTS.XREFS(cid), { params: { target }, }) return data } export async function fetchStrings( cid: string, minLength: number ): Promise { const { data } = await apiClient.get(API_ENDPOINTS.STRINGS(cid), { params: { min_length: minLength }, }) return data } export async function fetchProgress(session: string): Promise { const { data } = await apiClient.get(API_ENDPOINTS.PROGRESS, { params: { session }, }) return data } export async function submitAnswer( cid: string, body: SubmitRequest ): Promise { const { data } = await apiClient.post( API_ENDPOINTS.SUBMIT(cid), body ) return data }