[skip ci] Initial commit — CodexBar Mobile Expo app

This commit is contained in:
2026-06-24 16:28:28 +02:00
parent 4f32782eaf
commit 0bcd95ee1b
30 changed files with 3562 additions and 141 deletions
+25
View File
@@ -0,0 +1,25 @@
import type { CodexAuth, CodexUsageResponse } from "@/types/codex";
const USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
export async function fetchCodexUsage(auth: CodexAuth): Promise<CodexUsageResponse> {
const headers: Record<string, string> = {
Authorization: `Bearer ${auth.accessToken}`,
"Content-Type": "application/json",
};
if (auth.accountId) {
headers["ChatGPT-Account-Id"] = auth.accountId;
}
const response = await fetch(USAGE_URL, { headers });
if (response.status === 401 || response.status === 403) {
throw new Error("TOKEN_EXPIRED");
}
if (!response.ok) {
throw new Error(`HTTP_ERROR_${response.status}`);
}
return response.json() as Promise<CodexUsageResponse>;
}