Lichess OAuth provider

OAuth integration for Lichess. Provider id is lichess.

import { lichess } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";

const lichessAuth = lichess(auth, config);

lichess()#

const lichess: (
	auth: Auth,
	config: {
		clientId: string;
		redirectUri: string;
		scope?: string[];
	}
) => LichessProvider;
Parameter#
nametypedescriptionoptional
authAuthLucia instance
config.clientIdstringclient id - choose any unique client id
config.redirectUristringredirect URI
config.scopestring[]an array of scopes
Returns#
typedescription
LichessProviderLichess provider

Interfaces#

LichessAuth#

See OAuth2ProviderAuthWithPKCE.

// implements OAuth2ProviderAuthWithPKCE<LichessAuth<_Auth>>
interface LichessAuth<_Auth extends Auth> {
	getAuthorizationUrl: () => Promise<
		readonly [url: URL, codeVerifier: string, state: string]
	>;
	validateCallback: (
		code: string,
		codeVerifier: string
	) => Promise<LichessUserAuth<_Auth>>;
}
Generics#
nameextendsdefault
_AuthAuthAuth

LichessTokens#

type LichessTokens = {
	accessToken: string;
	accessTokenExpiresIn: number;
};

LichessUser#

type LichessUser = {
	id: string;
	username: string;
};

LichessUserAuth#

Extends ProviderUserAuth.

interface LichessUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
	lichessUser: LichessUser;
	lichessTokens: LichessTokens;
}
propertiestypedescription
lichessUserLichessUserLichess user
lichessTokensLichessTokensAccess tokens etc
Generics#
nameextends
_AuthAuth