11import { useCallback , useEffect , useRef , useState } from 'react'
2- import EncryptedStorage from 'react-native-encrypted-storage '
2+ import * as SecureStore from 'expo-secure-store '
33import RNFS from 'react-native-fs'
44import crypto from 'react-native-quick-crypto'
55import { useMutation , useQuery , UseQueryResult } from 'react-query'
@@ -762,16 +762,16 @@ export function useSavedAddress(): {
762762} {
763763 const { data : address , refetch } = useQuery < string | null > (
764764 [ 'xmtp' , 'address' ] ,
765- ( ) => EncryptedStorage . getItem ( 'xmtp.address' )
765+ ( ) => SecureStore . getItemAsync ( 'xmtp.address' )
766766 )
767767 return {
768768 address,
769769 save : async ( address : string ) => {
770- await EncryptedStorage . setItem ( 'xmtp.address' , address )
770+ await SecureStore . setItemAsync ( 'xmtp.address' , address )
771771 await refetch ( )
772772 } ,
773773 clear : async ( ) => {
774- await EncryptedStorage . removeItem ( 'xmtp.address' )
774+ await SecureStore . deleteItemAsync ( 'xmtp.address' )
775775 await refetch ( )
776776 } ,
777777 }
@@ -784,11 +784,11 @@ export async function getDbEncryptionKey(
784784 try {
785785 const key = `xmtp-${ network } `
786786
787- const result = await EncryptedStorage . getItem ( key )
787+ const result = await SecureStore . getItemAsync ( key )
788788 if ( ( result && clear === true ) || ! result ) {
789789 if ( result ) {
790790 console . log ( 'Removing existing dbEncryptionKey' , key )
791- await EncryptedStorage . removeItem ( key )
791+ await SecureStore . deleteItemAsync ( key )
792792 }
793793
794794 // Generate random bytes for the encryption key
@@ -797,7 +797,7 @@ export async function getDbEncryptionKey(
797797
798798 // Convert to string for storage
799799 const randomBytesString = uint8ArrayToHexString ( randomBytes )
800- await EncryptedStorage . setItem ( key , randomBytesString )
800+ await SecureStore . setItemAsync ( key , randomBytesString )
801801
802802 return randomBytes
803803 } else {
0 commit comments