expo-storage-universal-native
Version:
Native implementation of expo-storage-universal
93 lines (89 loc) • 3.82 kB
TypeScript
import { Storage as Storage_2 } from 'expo-storage-universal';
/**
* NativeRegularStorage class implementing the Storage interface for native platforms.
* Utilizes AsyncStorage for non-secure data storage on iOS and Android.
*/
export declare class NativeRegularStorage implements Storage_2 {
/**
* Creates a new instance of NativeRegularStorage.
*/
constructor();
/**
* Retrieves a value from AsyncStorage.
* @param {string} key - The key of the item to retrieve.
* @returns {Promise<string | undefined>} - A promise that resolves to the retrieved value or undefined if not found.
* @example
* const value = await storage.find('userId');
*/
find(key: string): Promise<string | undefined>;
/**
* Saves a value to AsyncStorage.
* @param {string} key - The key under which the value should be stored.
* @param {string} value - The value to store.
* @returns {Promise<void>} - A promise that resolves when the value has been saved.
* @example
* await storage.save('userId', '12345');
*/
save(key: string, value: string): Promise<void>;
/**
* Removes a value from AsyncStorage.
* @param {string} key - The key of the item to remove.
* @returns {Promise<void>} - A promise that resolves when the value has been removed.
* @example
* await storage.remove('userId');
*/
remove(key: string): Promise<void>;
}
/**
* NativeSecureStorage implements the Storage interface using Expo's SecureStore.
* This implementation provides secure storage capabilities for React Native applications,
* storing data in the device's secure storage system (Keychain on iOS, EncryptedSharedPreferences on Android).
*
* @remarks
* - Uses expo-secure-store for platform-specific secure storage implementation
* - Provides encryption at rest for stored data
* - Suitable for storing sensitive information like authentication tokens, API keys, and user credentials
* - Data persists across app restarts
*/
export declare class NativeSecureStorage implements Storage_2 {
/**
* Creates a new instance of NativeSecureStorage.
* No initialization is required as SecureStore is stateless.
*/
constructor();
/**
* Finds a value from secure storage.
* @param {string} key - The key of the item to retrieve.
* @returns {Promise<string | undefined>} - A promise that resolves to the retrieved value or undefined if not found.
* @throws {Error} If there's an error accessing the secure storage.
*
* @remarks
* - Returns undefined if the key doesn't exist
* - Automatically decrypts the stored value
*/
find(key: string): Promise<string | undefined>;
/**
* Saves a value to secure storage.
* @param {string} key - The key under which the value should be stored.
* @param {string} value - The value to store.
* @returns {Promise<void>} - A promise that resolves when the value has been saved.
* @throws {Error} If there's an error saving to secure storage.
*
* @remarks
* - Automatically encrypts the value before storage
* - If the key already exists, the value will be overwritten
*/
save(key: string, value: string): Promise<void>;
/**
* Removes a value from secure storage.
* @param {string} key - The key of the item to remove.
* @returns {Promise<void>} - A promise that resolves when the value has been removed.
* @throws {Error} If there's an error removing from secure storage.
*
* @remarks
* - No-op if the key doesn't exist
* - Permanently deletes the encrypted data
*/
remove(key: string): Promise<void>;
}
export { }