Remember my several recent posts talking about that "Local Data Lock" library?
There were lots of inquiries/feedback assuming that such a library should also handle local client-side storage (localStorage, IndexedDB, etc). I didn't think that LDL should handle this, as it was designed more narrowly to focus only on the encryption (and protecting the cryptographic key in a biometric passkey). With LDL, you *might* end up storing the encrypted data locally. Or maybe not.
----
HOWEVER!
I did take the point that making the storage part much easier, and especially abstracting across various client-side storage mechanisms, while still automatically handling the encryption (on write) and decryption (on read)... that was a useful idea and a library that should exist.
So I built it!
It's called "Local Vault". This library provides a simple key-value storage abstraction, backed by 5 different client-side storage mechanisms (IndexedDB, Local-Storage, Session-Storage, Cookies, and OPFS). It automatically handles the encryption key stuff, including the biometric passkeys.
Should make it dead-simple to build local-first web apps that protect user data on-device (no servers!), encrypted at rest, without requiring the user to do anything more than present a single biometric passkey factor (FaceID, TouchID, etc) to access or update their data. No insecure/troublesome passwords to worry about!
Example code:
import "@lo-fi/local-vault/adapter/idb"; // IndexedDB adapter
import { connect } from "@lo-fi/local-vault";
var vault = await connect({
storageType: "idb",
addNewVault: true
});
await vault.set("property","my value"); // true
await vault.get("property"); // "my value"
I'll link to this library github repo in the comments soon. But if you poke around my github commits you'll quickly find it. It's also on npm at "@lo-fi/local-vault".
Enjoy!