Giter Site home page Giter Site logo

Comments (5)

benjohnde avatar benjohnde commented on August 17, 2024

@rishabh876 feel free to give it a try!

from kvault.

benjohnde avatar benjohnde commented on August 17, 2024

@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.

yuroyami avatar yuroyami commented on August 17, 2024

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.

rishabh876 avatar rishabh876 commented on August 17, 2024

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.

cristhianescobar avatar cristhianescobar commented on August 17, 2024

Can someone make a release with this fix please?

from kvault.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.