14c880123c
Expo app with dashboard, time clock, invoices, and settings — native tabs, glass UI, theme-aware components, and iOS Live Activities. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import * as SecureStore from "expo-secure-store";
|
|
|
|
const ENABLED_KEY = "beenvoice_app_lock_enabled";
|
|
const PIN_KEY = "beenvoice_app_lock_pin";
|
|
const BIOMETRIC_KEY = "beenvoice_app_lock_biometric";
|
|
|
|
export async function getAppLockEnabled(): Promise<boolean> {
|
|
const value = await SecureStore.getItemAsync(ENABLED_KEY);
|
|
return value === "1";
|
|
}
|
|
|
|
export async function setAppLockEnabled(enabled: boolean): Promise<void> {
|
|
if (enabled) {
|
|
await SecureStore.setItemAsync(ENABLED_KEY, "1");
|
|
} else {
|
|
await SecureStore.deleteItemAsync(ENABLED_KEY);
|
|
}
|
|
}
|
|
|
|
export async function getStoredPin(): Promise<string | null> {
|
|
return SecureStore.getItemAsync(PIN_KEY);
|
|
}
|
|
|
|
export async function setStoredPin(pin: string): Promise<void> {
|
|
await SecureStore.setItemAsync(PIN_KEY, pin);
|
|
}
|
|
|
|
export async function clearStoredPin(): Promise<void> {
|
|
await SecureStore.deleteItemAsync(PIN_KEY);
|
|
}
|
|
|
|
export async function getBiometricEnabled(): Promise<boolean> {
|
|
const value = await SecureStore.getItemAsync(BIOMETRIC_KEY);
|
|
return value === "1";
|
|
}
|
|
|
|
export async function setBiometricEnabled(enabled: boolean): Promise<void> {
|
|
if (enabled) {
|
|
await SecureStore.setItemAsync(BIOMETRIC_KEY, "1");
|
|
} else {
|
|
await SecureStore.deleteItemAsync(BIOMETRIC_KEY);
|
|
}
|
|
}
|
|
|
|
export function isValidPin(pin: string): boolean {
|
|
return /^\d{4,6}$/.test(pin);
|
|
}
|