Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const _retrieveData = async key => {
try {
let value = await AsyncStorage.getItem(key);
if (value === null) value = await SecureStore.getItemAsync(key);
return value;
} catch (error) {
throw Error(`Unable to retrieve data from storage.`);
}
};
const _retrieveData = async (key): Promise => {
try {
let value = await AsyncStorage.getItem(key);
if (value === null) value = await SecureStore.getItemAsync(key);
return value;
} catch (error) {
throw Error(`Unable to retrieve data from storage.`);
}
};
export const getItem = async (name: string) => SecureStore.getItemAsync(name);
export const setItem = async (name: string, value: string) => SecureStore.setItemAsync(name, value);
detect: async (callback: (lang: string) => string) => {
const lng = await SecureStore.getItemAsync('i18nextLng');
return callback(lng || (await Localization.getLocalizationAsync()).locale.replace('_', '-'));
},
init: () => {},
return new Promise(async (resolve, reject) => {
try {
let value = null;
const aesKey = await SecureStore.getItemAsync(key, secureStoreOptions);
if (aesKey) {
const storageFileUri = await fixedStorageUri(secureStoreOptions);
if (storageFileUri) {
const storageString = await FileSystem.readAsStringAsync(storageFileUri);
const storage = JSON.parse(storageString);
const encryptedValue = storage[key];
value = AES.decrypt(encryptedValue, aesKey);
}
}
resolve(value);
} catch (e) {
reject(e);
}
});
};