lucia-auth
БесплатноБез исполняемых скриптовНе проверенLucia was a TypeScript library for database-backed session authentication. Its npm package was deprecated in March 2025 and the project now ships one…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Lucia Auth — Session Authentication Without the Library
Overview
Lucia was a small TypeScript library that stored sessions in your database and handed you a cookie. It is no longer a library you install. Status checked on 2026-10-01:
lucia3.2.2 (October 2024) is the last release. The package and every@lucia-auth/adapter-*package are marked deprecated on npm; the author deprecated them in March 2025 because the adapter model was too rigid and sessions are short enough to write by hand.- The repository
lucia-auth/lucianow contains a README andcode/auth_session.ts, a single 0BSD-licensed file that replaces the package. The migration page that the npm warning links to (lucia-auth.com/lucia-v3/migrate) was removed in July 2026 and returns 404. - On 2026-07-29 the same author deprecated
arctic(OAuth clients) and the@oslojs/*packages (@oslojs/crypto,@oslojs/jwtand the rest) except@oslojs/encoding; the olderoslopackage was already deprecated. - The v3 documentation is still readable at
v3.lucia-auth.com. The author's current material is the Auth Book atauth.pilcrowonpaper.com.
So "use Lucia" today means: own a session module of about fifty lines. This skill gives that module and the path off Lucia v3. For a maintained library with OAuth providers, two-factor, passkeys or organizations, use the better-auth or authjs skill instead.
Instructions
Choose a path
| Situation | What to do |
|---|---|
| New project, "set up Lucia" | Do not install lucia. Write the session module below, or pick a maintained library. |
| App already on Lucia v3 | It keeps running but gets no fixes. Swap in the v3-compatible module (Example 2); no database change, nobody is signed out. |
OAuth through arctic |
Deprecated. Send the authorization and token requests directly; arcticjs.dev links one example file per step, and the oauth2-oidc skill covers the flow. |
Imports from oslo or @oslojs/* |
Only @oslojs/encoding is maintained. Use Web Crypto (crypto.subtle, crypto.getRandomValues) and @node-rs/argon2. |
Session table
CREATE TABLE user (
id TEXT NOT NULL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL
) STRICT;
CREATE TABLE auth_session (
id TEXT NOT NULL PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES user(id),
secret_hash BLOB NOT NULL, -- SHA-256 of the token secret; BYTEA on PostgreSQL
last_verified_at INTEGER NOT NULL, -- unix seconds
created_at INTEGER NOT NULL
) STRICT;
On PostgreSQL user is a reserved word; name the table app_user there.
Session module
The token given to the browser is id.secret. The database stores only a hash of the secret, so a leaked table cannot be replayed as cookies, and the secret is compared in constant time.
// auth/session.ts — what `new Lucia(adapter)` used to provide, in one file you own
import Database from "better-sqlite3";
const db = new Database(process.env.DATABASE_PATH ?? "app.db");
export const SESSION_TTL_SECONDS = 60 * 60 * 24 * 10; // expires after 10 days without activity
export interface AuthSession { id: string; userId: string; lastVerifiedAt: number; createdAt: number }
const hex = (bytes: Uint8Array) => Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
const sha256 = async (bytes: Uint8Array<ArrayBuffer>) => new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean {
if (a.byteLength !== b.byteLength) return false;
let diff = 0;
for (let i = 0; i < a.byteLength; i++) diff |= a[i]! ^ b[i]!;
return diff === 0;
}
export async function createSession(userId: string): Promise<{ session: AuthSession; token: string }> {
const id = hex(crypto.getRandomValues(new Uint8Array(12)));
const secret = crypto.getRandomValues(new Uint8Array(32));
const now = Math.floor(Date.now() / 1000);
db.prepare("INSERT INTO auth_session (id, user_id, secret_hash, last_verified_at, created_at) VALUES (?, ?, ?, ?, ?)")
.run(id, userId, await sha256(secret), now, now);
return { session: { id, userId, lastVerifiedAt: now, createdAt: now }, token: `${id}.${hex(secret)}` };
}
export async function validateSessionToken(token: string): Promise<AuthSession | null> {
const [id, secretHex, ...extra] = token.split(".");
if (!id || !secretHex || extra.length > 0 || !/^[0-9a-f]{64}$/.test(secretHex)) return null;
const row = db.prepare("SELECT user_id, secret_hash, last_verified_at, created_at FROM auth_session WHERE id = ?").get(id) as
| { user_id: string; secret_hash: Uint8Array; last_verified_at: number; created_at: number } | undefined;
if (!row) return null;
const now = Math.floor(Date.now() / 1000);
if (now - row.last_verified_at >= SESSION_TTL_SECONDS) {
db.prepare("DELETE FROM auth_session WHERE id = ?").run(id);
return null;
}
const secret = Uint8Array.from(secretHex.match(/../g)!, (pair) => parseInt(pa
Установить lucia-auth в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл lucia-auth?
Lucia was a TypeScript library for database-backed session authentication. Its npm package was deprecated in March 2025 and the project now ships one reference file for writing the session code yourself. Use when a project imports `lucia` or `@lucia-auth/adapter-*`, when npm prints the lucia deprecation warning, or when someone asks to "add Lucia auth", "migrate off Lucia v3", "implement sessions like Lucia", or "replace Arctic". Covers the project's current status, a hand-written session module (create, validate, invalidate, cookies, CSRF), password hashing, and a replacement that keeps existing Lucia v3 sessions valid.
Как установить скилл lucia-auth?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл lucia-auth запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic