earthstar-project / earthstar

Storage for private, distributed, offline-first applications.
https://earthstar-project.org
GNU Lesser General Public License v3.0
623 stars 18 forks source link

Add way to check if given password is correct on Auth #340

Open sgwilym opened 1 month ago

sgwilym commented 1 month ago

What's the problem you want solved?

Currently the only way to check if a password is correct for a given Auth is to instantiate a new one and see if it throws or not. Even then you can't be sure because the password may not have been set up yet. This makes it hard to build applications where you may want to more gracefully check if the given password is correct or not.

Is there a solution you'd like to recommend?

Add a Auth.checkPassword(storage) static method which checks the password against the given storage. It should return different results depending on whether the password is correct, incorrect, or whether no password has been set yet.