Conversation
|
Hey @mattlennon3 |
|
It can be very useful for migration from mCodex/react-native-sensitive-info to this library |
|
Hi @DorianMazur , thanks for the response. Sorry I've not added any README changes or other documentation yet, I've had to put my upgrade on hold to fix some other issues. But I'm ramping back up now. To your question, because of the limited retrieval functionality I believe a migration step is not possible, as I alluded to in my description:
I am referring to There is also no period where we can have both
So if you want, I could refactor this PR to have the ability to return the array of passwords, but not set them. Then a migration step is possible. Or we can keep the full functionality of updating the array of passwords, which I do think is valid as it prevents this arguably "heavy" serialising/deserialising of data. |
This MR makes it possible to store an array of items in the keychain.
Reason for MR
I am raising this MR because I wanted to migrate our project from using
react-native-sensitive-infoto usingreact-native-keychain. This repo is actually maintained and has a larger community using it. Also the sensitive info library seems to stop working after upgrading RN0.76.1+mCodex/react-native-sensitive-info#424 (comment). So, time to move on!However, during testing I found that this library only returns a single object from the keychain. Which seems to be intended looking at comments here: #36 (comment), I should be serialising my data structure and storing it as a string in this single object.
This would be fine if I was starting a new project, but losing access to data already in the keychain was not acceptable as we would lose important login keys etc. So I decided to convert the functionality over to this library. Hopefully this will help others convert to this library and add some nice new functionality for existing users.
Changes
I have added these functions:
getItemForKeygetAllItemssetItemForKeyremoveItemForKeyclearItems.Of course a requirement for me was to mirror as best as possible the behaviour of the functions in
react-native-sensitive-info. So I can preserve my data after migrating to this library.I feel like the iOS implementation fits in nicely with the existing code. But I will admit that the Android side was more complex, you guys have a
DataStorePrefsStorageclass that I wasn't sure how exactly to integrate with, so I played it safe and kept to a simple implementation within the mainKeychainModule. Would appreciate any pointers for this.Thanks and any feedback is welcome 🙏