[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
+44
View File
@@ -0,0 +1,44 @@
import type { ClaudeOrg, ClaudeUsageResponse } from "@/types/claude";
const BASE_URL = "https://claude.ai/api";
function cookieHeader(sessionKey: string): Record<string, string> {
return {
Cookie: `sessionKey=${sessionKey}`,
"Accept": "application/json",
"Origin": "https://claude.ai",
};
}
export async function fetchClaudeOrgs(sessionKey: string): Promise<ClaudeOrg[]> {
const response = await fetch(`${BASE_URL}/organizations`, {
headers: cookieHeader(sessionKey),
});
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<ClaudeOrg[]>;
}
export async function fetchClaudeUsage(
sessionKey: string,
orgUuid: string
): Promise<ClaudeUsageResponse> {
const response = await fetch(`${BASE_URL}/organizations/${orgUuid}/usage`, {
headers: cookieHeader(sessionKey),
});
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<ClaudeUsageResponse>;
}