Skip to content

Commit fed92c0

Browse files
authored
Replace outdated "React Native Encrypted Storage" with "Expo Secure Store" (#762)
1 parent 8898e75 commit fed92c0

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

example/app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"photosPermission": "The app accesses your photos to let you attach them as messages.",
2222
"cameraPermission": "The app accesses your camera to let you attach photos as messages."
2323
}
24-
]
24+
],
25+
"expo-secure-store"
2526
],
2627
"ios": {
2728
"supportsTablet": true,

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"expo-document-picker": "~13.0.3",
3333
"expo-file-system": "~18.0.12",
3434
"expo-image-picker": "~16.0.6",
35+
"expo-secure-store": "~14.0.1",
3536
"expo-splash-screen": "~0.29.24",
3637
"expo-status-bar": "~2.0.1",
3738
"expo-system-ui": "~4.0.9",
@@ -42,7 +43,6 @@
4243
"react-native-blob-util": "^0.19.0",
4344
"react-native-config": "^1.5.1",
4445
"react-native-crypto": "^2.2.0",
45-
"react-native-encrypted-storage": "^4.0.3",
4646
"react-native-fs": "^2.20.0",
4747
"react-native-get-random-values": "^1.11.0",
4848
"react-native-mmkv": "^2.8.0",

example/src/hooks.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useCallback, useEffect, useRef, useState } from 'react'
2-
import EncryptedStorage from 'react-native-encrypted-storage'
2+
import * as SecureStore from 'expo-secure-store'
33
import RNFS from 'react-native-fs'
44
import crypto from 'react-native-quick-crypto'
55
import { 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 {

example/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,6 +4196,11 @@ [email protected]:
41964196
dependencies:
41974197
invariant "^2.2.4"
41984198

4199+
expo-secure-store@~14.0.1:
4200+
version "14.0.1"
4201+
resolved "https://registry.yarnpkg.com/expo-secure-store/-/expo-secure-store-14.0.1.tgz#8953d5966430f5ff262f4d99e7551205870078d7"
4202+
integrity sha512-QUS+j4+UG4jRQalgnpmTvvrFnMVLqPiUZRzYPnG3+JrZ5kwVW2w6YS3WWerPoR7C6g3y/a2htRxRSylsDs+TaQ==
4203+
41994204
expo-splash-screen@~0.29.24:
42004205
version "0.29.24"
42014206
resolved "https://registry.yarnpkg.com/expo-splash-screen/-/expo-splash-screen-0.29.24.tgz#4e5f6d576d3fbb37c5e3e4ee6d3f3b3ece350f75"
@@ -6955,11 +6960,6 @@ react-native-crypto@^2.2.0:
69556960
public-encrypt "^4.0.0"
69566961
randomfill "^1.0.3"
69576962

6958-
react-native-encrypted-storage@^4.0.3:
6959-
version "4.0.3"
6960-
resolved "https://registry.npmjs.org/react-native-encrypted-storage/-/react-native-encrypted-storage-4.0.3.tgz#2a4d65459870511e8f4ccd22f02433dab7fa5e91"
6961-
integrity sha512-0pJA4Aj2S1PIJEbU7pN/Qvf7JIJx3hFywx+i+bLHtgK0/6Zryf1V2xVsWcrD50dfiu3jY1eN2gesQ5osGxE7jA==
6962-
69636963
react-native-fs@^2.20.0:
69646964
version "2.20.0"
69656965
resolved "https://registry.npmjs.org/react-native-fs/-/react-native-fs-2.20.0.tgz#05a9362b473bfc0910772c0acbb73a78dbc810f6"

0 commit comments

Comments
 (0)