
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
expo-encrypted-storage
Advanced tools
Expo wrapper to React Native Encrypted Storage.
yarn
$ yarn add expo-encrypted-storage
npm
$ npm install expo-encrypted-storage
Since version 0.60, React Native supports auto linking. This means no additional step is needed on your end.
$ react-native link expo-encrypted-storage
Special note for iOS using cocoapods
, run:
$ npx pod-install
This module exposes four (4) native functions to store, retrieve, remove and clear values. They can be used like so:
import ExpoEncryptedStorage from "expo-encrypted-storage";
async function storeUserSession() {
try {
await ExpoEncryptedStorage.setItemAsync(
"user_session",
JSON.stringify({
age: 21,
token: "ACCESS_TOKEN",
username: "emeraldsanto",
languages: ["fr", "en", "de"],
})
);
// Congrats! You've just stored your first value!
} catch (error) {
// There was an error on the native side
}
}
async function retrieveUserSession() {
try {
const session = await ExpoEncryptedStorage.getItemAsync("user_session");
if (session !== undefined) {
// Congrats! You've just retrieved your first value!
}
} catch (error) {
// There was an error on the native side
}
}
async function removeUserSession() {
try {
await ExpoEncryptedStorage.removeItemAsync("user_session");
// Congrats! You've just removed your first value!
} catch (error) {
// There was an error on the native side
}
}
async function clearStorage() {
try {
await ExpoEncryptedStorage.clearAsync();
// Congrats! You've just cleared the device storage!
} catch (error) {
// There was an error on the native side
}
}
Take the removeItem
example, an error can occur when trying to remove a value which does not exist, or for any other reason. This module forwards the native iOS Security framework error codes to help with debugging.
async function removeUserSession() {
try {
await ExpoEncryptedStorage.removeItemAsync("user_session");
} catch (error) {
// There was an error on the native side
// You can find out more about this error by using the `error.code` property
console.log(error.code); // ex: -25300 (errSecItemNotFound)
}
}
There seems to be some confusion around the maximum size of items that can be stored, especially on iOS. According to this StackOverflow question, the actual Keychain limit is much lower than what it should theoretically be. This does not affect Android as the EncryptedSharedPreferences
API relies on the phone's storage, via XML files.
MIT
FAQs
Secure Storage
We found that expo-encrypted-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.