Authentication

Etebase automatically takes care of the encryption for you, securely deriving an encryption key from the user password. It then also creates an asymmetric keypair to login so the password never leaves the user's device.

important

Please note that all of the operations in this page are slow and may take a few seconds to complete depending on your device. This is because Etebase purpusefully uses a slow function (Argon2id) to derive a secure encryption key from the user password.

Luckily they can be avoided almost entirely for most use-cases. Pleaes take a look at session save and restore for more information.

Signup

Sign up is just one easy call which returns an instance of the main etebase class.

const etebase = await Etebase.Account.signup("username", "password");

Login

Login is too just one easy call which returns an instance of the main etebase class.

const etebase = await Etebase.Account.login("username", "password");

Change password

Unlike signup and login, changing password requires an already set up etebase object.

await etebase.changePassword("new password");

Logout

await etebase.logout();

Session save and restore

Most apps can't, or don't want the user to enter their passwords every time they are opened, that's why Etebase supports saving and restoring sessions.

Saving and restoring a session is as simple as:

const etebase = await Etebase.Account.login("username", "password");
const savedSession = await etebase.save();
// Later on...
const etebase = await Etebase.Account.restore(savedSession);

Encrypting the stored session

While the above works, it's advised to encrypt the stored session with a randomly generated key that is stored securely (e.g. in the operating system's key store), or securely derived from a user storage password.

const etebase = await Etebase.Account.login("username", "password");
// Save the key somewhere safe (e.g. the OS's key store)
const encryptionKey = Etebase.randomBytes(32);
const savedSession = await etebase.save(encryptionKey);
// Later on...
const etebase = await Etebase.Account.restore(savedSession, encryptionKey);

Checking custom server URL

The login and signup operations above automatically check whether the URL passed is pointing to a valid Etebase server. However, some applications need to know if the URL is pointing to a valid server before asking for credentials. This function does exactly that.

const isEtebase = await Etebase.Account.isEtebaseServer("https://example.com");