import { NativeModules } from 'react-native' ; const { RNEncryptedStorage } = NativeModules ; if ( ! RNEncryptedStorage ) { throw new Error ( 'RNEncryptedStorage is undefined' ) ; } export type StorageErrorCallback = ( error ? : Error ) => void ; export type StorageValueCallback = ( error ? : Error , value ? : string ) => void ; export default class EncryptedStorage { param { string } key param { string } value static setItem ( key , value ) ; param { string } key param { string } value param { Function } cb static setItem ( key , value , cb ) ; static setItem ( key , value , cb ? ) { if ( cb ) { RNEncryptedStorage . setItem ( key , value ) . then ( cb ) . catch ( cb ) ; return ; } return RNEncryptedStorage . setItem ( key , value ) ; } param { string } key static getItem ( key ) ; param { string } key param { Function } cb static getItem ( key , cb ) ; static getItem ( key , cb ? ) { if ( cb ) { RNEncryptedStorage . getItem ( key ) . then ( cb ) . catch ( cb ) ; return ; } return RNEncryptedStorage . getItem ( key ) ; } param { string } key static removeItem ( key ) ; param { string } key param { Function } cb static removeItem ( key , cb ) ; static removeItem ( key , cb ? ) { if ( cb ) { RNEncryptedStorage . removeItem ( key ) . then ( cb ) . catch ( cb ) ; return ; } return RNEncryptedStorage . removeItem ( key ) ; } /**
     * Clears all data from disk, using SharedPreferences or KeyChain, depending on the platform.
     */ static clear ( ) ; param { Function } cb static clear ( cb ) ; static clear ( cb ? ) { if ( cb ) { RNEncryptedStorage . clear ( ) . then ( cb ) . catch ( cb ) ; return ; } return RNEncryptedStorage . clear ( ) ; } }