[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
+34
View File
@@ -0,0 +1,34 @@
import * as DocumentPicker from "expo-document-picker";
import { File } from "expo-file-system/next";
import type { CodexAuth } from "@/types/codex";
export async function pickAndReadCodexAuth(): Promise<CodexAuth> {
const result = await DocumentPicker.getDocumentAsync({
type: "application/json",
copyToCacheDirectory: true,
});
if (result.canceled) {
throw new Error("PICKER_CANCELLED");
}
const { uri } = result.assets[0];
const file = new File(uri);
const text = file.text();
let parsed: Record<string, unknown>;
try {
parsed = JSON.parse(text);
} catch {
throw new Error("INVALID_JSON");
}
const accessToken = parsed["accessToken"] as string | undefined;
const accountId = parsed["accountId"] as string | undefined;
if (!accessToken || typeof accessToken !== "string") {
throw new Error("MISSING_ACCESS_TOKEN");
}
return { accessToken, accountId };
}