export interface RequestOptions { baseUrl: string; token: string; anonymousPacketToken: string; apiKey: string; hmacSecret: string; encryptRequests: boolean; csrfEnabled: boolean; csrfHeaderName: string; csrfCookieName: string; refreshCsrfCookie: (() => Promise) | null; onAccessToken?: (token: string) => void; requestAbortControllers: Map; /** * dev 디버그 평문 시크릿. 설정되면 요청을 암호화하지 않고(평문), * `X-Debug-Plain` 헤더로 전송한다. 서버의 `DEBUG_PLAIN_SECRET` 과 일치하면 * 서버도 해당 요청/응답을 평문으로 처리한다(패킷 암호화 우회). */ debugPlainSecret?: string; } export interface EntityRequestConfig { requireOkShape?: boolean; allowStatuses?: number[]; signal?: AbortSignal; autoAbortKey?: string | false; } export interface EntityRequestError extends Error { status?: number; code?: string; details?: unknown; } /** * Entity Server에 HTTP 요청을 보냅니다. * * - `encryptRequests` 활성화 시 인증된 POST 바디를 자동 암호화합니다. * - 응답이 `application/octet-stream`이면 자동 복호화합니다. * - JSON 응답의 `ok`가 false이면 에러를 던집니다. */ export declare function entityRequest(opts: RequestOptions, method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record, config?: boolean | EntityRequestConfig): Promise; /** 업로드 진행률 콜백이다. (loaded/total 은 byte 단위) */ export type UploadProgressHandler = (loaded: number, total: number) => void; /** * multipart/form-data(파일 업로드) 요청을 패킷 암호화와 무관하게 보낸다. * * 파일 업로드는 요청 본문(FormData)을 암호화하지 않는다. 서버가 multipart 를 그대로 파싱하기 때문이다. * 다만 패킷 암호화가 켜진 서버는 **응답**을 `application/octet-stream` 으로 암호화해 내려줄 수 있으므로, * 일반 `entityRequest` 와 동일하게 `X-Debug-Plain`/`X-Packet-Token`/HMAC 헤더를 실어 보내고 * 응답 Content-Type 에 따라 (octet-stream 이면 복호화, 아니면 JSON) 자동 처리한다. * * 기존 raw `fetch + res.json()` 방식은 암호화 응답을 복호화하지 못해 * `Unexpected token '...' is not valid JSON` 으로 깨졌다. (HTTP 200 이어도) * * `onUploadProgress` 를 넘기면 fetch 대신 XHR 로 전송해 업로드 진행률을 콜백으로 알린다. */ export declare function requestFormData(opts: RequestOptions, method: string, path: string, form: FormData, withAuth?: boolean, onUploadProgress?: UploadProgressHandler): Promise;