Files
codexbar-mobile/lib/storage.ts
T

39 lines
1.1 KiB
TypeScript

import * as SecureStore from "expo-secure-store";
const KEYS = {
CODEX_AUTH: "codexbar_codex_auth",
CLAUDE_SESSION_KEY: "codexbar_claude_session_key",
} as const;
export async function saveCodexAuth(auth: {
accessToken: string;
accountId?: string;
}): Promise<void> {
await SecureStore.setItemAsync(KEYS.CODEX_AUTH, JSON.stringify(auth));
}
export async function loadCodexAuth(): Promise<{
accessToken: string;
accountId?: string;
} | null> {
const raw = await SecureStore.getItemAsync(KEYS.CODEX_AUTH);
if (!raw) return null;
return JSON.parse(raw) as { accessToken: string; accountId?: string };
}
export async function saveClaudeSessionKey(key: string): Promise<void> {
await SecureStore.setItemAsync(KEYS.CLAUDE_SESSION_KEY, key);
}
export async function loadClaudeSessionKey(): Promise<string | null> {
return SecureStore.getItemAsync(KEYS.CLAUDE_SESSION_KEY);
}
export async function clearCodexAuth(): Promise<void> {
await SecureStore.deleteItemAsync(KEYS.CODEX_AUTH);
}
export async function clearClaudeSessionKey(): Promise<void> {
await SecureStore.deleteItemAsync(KEYS.CLAUDE_SESSION_KEY);
}