Auth primitives for the JS ecosystem — stateless encrypted sessions, password hashing, and two-factor support. Zero framework dependencies; inspired by Laravel's Auth and Hash facades. Current stable version is 1.2.0, released monthly. Key differentiators: uses iron-session for AES-256-CBC + HMAC encrypted cookies, supports two session modes (resolveUser for DB-backed, sessionFields for zero DB calls), built-in TOTP for 2FA, and per-request autoTouch override for frameworks like Next.js. Ships TypeScript types, requires Node >=18, and has optional bcryptjs peer dependency.
npm install ideal-authVerified import paths — ran on the pinned version, not inferred.
Shows setup with createAuth and createHash, cookie bridge for Next.js, and basic login/check/logout flow.
Update to createAuth<SessionUser>({ ... }) — remove the second type argument.Migrate to single generic: createAuth<SessionUser>({ ... }).Rename environment variable to IDEAL_AUTH_SECRET.
Upgrade to v1.2.0 or later to use auth({ autoTouch: true }).Install bcryptjs as a dependency if using createHash() or provide a custom HashInstance.
Use 'as const' when defining sessionFields array.
Generate a 32+ character secret via 'bunx ideal-auth secret'.
Generate a 32+ character secret: bunx ideal-auth secret, then add to .env.
Run: npm install bcryptjs or provide a custom HashInstance.
Add 'as const' to the sessionFields array: const sessionFields = ['email', 'name'] as const;
Ensure auth() is called with await: const session = await auth();
Regenerate IDEAL_AUTH_SECRET and clear all session cookies.