Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

auth.ts

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

auth.tsBlame58 lines · 1 contributor
c53cf00Claude1import * as SecureStore from 'expo-secure-store';
2import { api, type User } from '../api/client';
3
4const TOKEN_KEY = 'gluecron_token';
5const USER_KEY = 'gluecron_user';
6const HOST_KEY = 'gluecron_host';
7
8export async function saveToken(token: string): Promise<void> {
9 await SecureStore.setItemAsync(TOKEN_KEY, token);
10 api.setToken(token);
11}
12
13export async function loadToken(): Promise<string | null> {
14 const token = await SecureStore.getItemAsync(TOKEN_KEY);
15 if (token) {
16 api.setToken(token);
17 }
18 return token;
19}
20
21export async function clearToken(): Promise<void> {
22 await SecureStore.deleteItemAsync(TOKEN_KEY);
23 api.clearToken();
24}
25
26export async function saveUser(user: User): Promise<void> {
27 await SecureStore.setItemAsync(USER_KEY, JSON.stringify(user));
28}
29
30export async function loadUser(): Promise<User | null> {
31 const raw = await SecureStore.getItemAsync(USER_KEY);
32 if (!raw) return null;
33 try {
34 return JSON.parse(raw) as User;
35 } catch {
36 return null;
37 }
38}
39
40export async function clearUser(): Promise<void> {
41 await SecureStore.deleteItemAsync(USER_KEY);
42}
43
44export async function saveHost(host: string): Promise<void> {
45 await SecureStore.setItemAsync(HOST_KEY, host);
46}
47
48export async function loadHost(): Promise<string | null> {
49 return SecureStore.getItemAsync(HOST_KEY);
50}
51
52export async function clearAll(): Promise<void> {
53 await Promise.all([
54 SecureStore.deleteItemAsync(TOKEN_KEY),
55 SecureStore.deleteItemAsync(USER_KEY),
56 ]);
57 api.clearToken();
58}