0.393 (21 Aug 2024)

21 August, 2024

Generated client upgraded

As you might already know, running keel client generates a complete TypeScript SDK (opens in a new tab) for you to authenticate with and query your Keel application.

In this release we have made some important changes to the authentication functions in the generated client.

⚠️

Note that this release introduced some breaking changes to the generated client.

createIfNotExists and identityCreated

The authenticateWithPassword() and authenticateWithIdToken() now accept the optional argument createIfNotExists. By setting this to false the authentication flow will only "log in" - i.e. it will only authenticate if the identity already exists and will not create the identity otherwise. This is really useful when you need to differentiate between "log in" and "sign up" flows.

All three authenticatee functions now return the field identityCreated, which indicates whether an new identity was created during the auth flow.

const res = await keel.client.authenticateWithPassword(...);
 
if (res.data.identityCreated) {
    // The identity was created - i.e. sign up
} else {
    // The identity was created - i.e. log in
}

Object inputs

We have changed the shape of the arguments to authenticateWithPassword(), authenticateWithIdToken() and authenticateWithSingleSignOn. Previously, they had accepted multiple arguments (e.g., (email, password)), however they will now take accept the arguments as fields of an object (e.g., ({ email: email, password: pass })).

For example, calling authenticateWithPassword() might look something like this:

const res = await keel.client.authenticateWithPassword({ 
    email: "me@user.com",
    password: "p@55w0rd",
    createIfNotExists: false
});

Returning errors

We have decided to change our approach to errors on the authentication functions and not throw them. This means that most of the auth functions can now return errors, which is aligned to how actions are handled on the generated client.

const res = await keel.client.authenticateWithPassword(...);
 
if (res.error) {
    switch res.error.type {
        case "unauthorized":
            // Failed to authenticate
        default:
            // Some other error occurred
    }
}

Please make sure to update your CLI by running npm install -g keel.

For any issues or feedback, please visit the support channel on our community Discord (opens in a new tab) or contact us at help@keel.so.

Thank you for using Keel!