Fix form keyboard issues and sticky footers in agent screens
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import * as Keychain from 'react-native-keychain';
|
||||
|
||||
import type { AuthTokens } from '../../types/app';
|
||||
|
||||
const BIOMETRIC_KEY = 'bankcbs.biometricEnabled';
|
||||
const SESSION_SERVICE = 'com.bankcbs.mobile.session';
|
||||
|
||||
export const secureStorage = {
|
||||
async saveSession(tokens: AuthTokens) {
|
||||
await Keychain.setGenericPassword('session', JSON.stringify(tokens), {
|
||||
service: SESSION_SERVICE,
|
||||
accessible: Keychain.ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
|
||||
securityLevel: Keychain.SECURITY_LEVEL.SECURE_SOFTWARE,
|
||||
});
|
||||
},
|
||||
|
||||
async getSession(): Promise<AuthTokens | null> {
|
||||
const credentials = await Keychain.getGenericPassword({
|
||||
service: SESSION_SERVICE,
|
||||
});
|
||||
|
||||
if (!credentials) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return JSON.parse(credentials.password) as AuthTokens;
|
||||
},
|
||||
|
||||
async getAccessToken() {
|
||||
const session = await this.getSession();
|
||||
return session?.accessToken ?? null;
|
||||
},
|
||||
|
||||
async clearSession() {
|
||||
await Keychain.resetGenericPassword({
|
||||
service: SESSION_SERVICE,
|
||||
});
|
||||
},
|
||||
|
||||
async setBiometricEnabled(value: boolean) {
|
||||
await AsyncStorage.setItem(BIOMETRIC_KEY, JSON.stringify(value));
|
||||
},
|
||||
|
||||
async getBiometricEnabled() {
|
||||
const value = await AsyncStorage.getItem(BIOMETRIC_KEY);
|
||||
return value ? JSON.parse(value) : false;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user