react-native-encrypted-storage
react-native-encrypted-storage copied to clipboard
Add support for storage options
Hi @emeraldsanto, thank you for this great library! This PR adds support for storage options, namely:
-
keychainAccessibility
on iOS, via kSecAttrAccessible -
storageName
, which uses kSecAttrService on iOS and fileName on Android
Both are optional and have sensible defaults (which we can change if you think it's required).
In terms of the API, I added an options
object as the previous to last parameter to all methods (before the optional cb
).
import EncryptedStorage, {
KeychainAccessibility,
} from 'react-native-encrypted-storage'
await EncryptedStorage.setItem(key, value, {
storageName: 'myStorage',
keychainAccessibility: KeychainAccessibility.kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
})
Following semver, this would be a breaking change in the function signature, so I suppose it requires a major version bump (if you agree with the API / approach).
Please let me know what you think.
@emeraldsanto could you have a look at this?
We are storing JWT refresh tokens in react-native-encrypted-storage
and are seeing quite a lot of error -25308 on iOS (and other people in https://github.com/emeraldsanto/react-native-encrypted-storage/issues/29 do as well).
It would make a lot of sense for us to set keychainAccessibility
to kSecAttrAccessibleWhenUnlocked
, which this PR allows.
#91 also points a potential issue with this.
This would be helpful to have for our business use case as well 👍
@emeraldsanto any plans to merge this PR? This'll solve several issues all of us are facing.
Will this pull request be merged?
Also looking for this to be merged as it would resolve thousands of Sentry errors. Any update?
Any updates? @emeraldsanto
I have same problem. Should I wait for merge or make patch?