0.1.0 • Published 2 years ago

lucia-appwrite-adapter v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Appwrite adapter for AppWrite

This is a community supported and cannot be guaranteed to work with the latest version of Lucia

Lucia documentation: https://lucia-sveltekit.vercel.app

Installation

npm install @lucia-sveltekit/adapter-appwrite

Usage

import appwrite from "@lucia-sveltekit/adapter-appwrite";

const config = {
    project_id: "",
    api: {
        endpoint: "",
        key: "",
    },
    database: {
        id: "",
        user_collection_id: "",
        refresh_token_collection_id: "",
    },
};

const auth = lucia({
    adapter: appwrite(config),
    // ...
});

Parameters

nametypedescription
config.project_idstringAppWrite project id
config.api.endpointstringProject api endpoint
config.api.keystringApi Key (Permissions: select all)
config.database.idstringDatabase id
config.database.user_collection_idstringCollection id of user
config.database.refresh_token_collection_idstringCollection id of refresh_token

Collections

user

user may have additional columns (which are represented by [user_data]).

Attributes

attribute idtyperequired
identifier_tokenstring (length: 255)true
hashed_passwordstring (length: 255)
user_dataanyany

Indexes

index keytypeattributes
user_idunique$id (ASC)
identifier_tokenuniqueidentifier_token (ASC)
user_dataanyany

refresh_token

Attributes

attribute idtyperequired
refresh_tokenstring (length: 300)true
user_idstring (length: 20)true

Indexes

index keytypeattributes
refresh_tokenuniquerefresh_token (ASC)
user_idkeyuser_id (ASC)

Issues

  • Lucia will return AUTH_DUPLICATE_USER_DATA error instead of AUTH_DUPLICATE_IDENTIFIER_TOKEN.

Testing

Configure the following:

const projectId = "";
const apiKey = "";
const databaseId = "";
const userCollectionId = "";
const refreshTokenCollectionId = "";

and run:

npm run test