Comments (5)
@rishabh876 feel free to give it a try!
from kvault.
@rishabh876 you can actually perform the KVault calls async, after some thinking I believe this is suboptimal, we do not really have an async alternative on iOS and just using commit does not guarantee that the shared prefs were written. Which seems to be okay (in some circumstances) for shared prefs but for secrets I would certainly want some "guarantee" rather than a "will probably be saved". You can reproduce cases in which data gets lost (commit and quick app crash or closing).
from kvault.
Under the hood, .commit()
simply executes the operation on the current thread, whilst .apply()
delegates it to an ephemeral background thread not controlled by you. .commit()
rather gives you thread control, you can make use of the kotlin coroutines to do what you're aiming for:
val prefScope = CoroutineScope(Dispatchers.IO + prefMotherJob)
...
prefScope.launch {
KVault.set()...
}
from kvault.
I tried moving set operation of KVault to IO thread. Turns out keystore are not thread safe on some devices. I started seeing
KeyStoreException the master key android-keystore://_androidx_security_master_key_ exists but is unusable
caused by -> IllegalBlockSizeException caused by -> KeyStoreException - Invalid operation handle
After digging a bit more I stumbled upon this thread. FlowCrypt/flowcrypt-android#235 (comment) which suggests its a Thread safety issue.
I would highly recommend adding this thread-safety disclaimer in documentation of Kvault as well. It must always be used on main thread.
from kvault.
Can someone make a release with this fix please?
from kvault.
Related Issues (20)
- Test clear method thoroughly
- Update documentation
- iOS Memory Leak Issue HOT 2
- iOS Memory Leak 2 HOT 2
- Add library to multiplatform library lists HOT 2
- Accessing Context in Shared Android HOT 1
- SharedPreferences `fileName` argument injection HOT 4
- First step fails: gradle error HOT 1
- Add support for retrieving all keys HOT 3
- [Question] Min SDK Version HOT 1
- Any plans to release the latest version of master? HOT 2
- Does writing values to kmmPreference work asynchronously? HOT 1
- API as an interface HOT 1
- Example or template for iOS HOT 1
- Support Binary Data HOT 1
- iOS Kotlin Tests not working HOT 1
- Add JS target support HOT 1
- Not able to run the KVault library code in ios.
- KVault initialization requires file name to change to avoid EncryptedSharedPreferences crash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kvault.