Main entry point for the libts-csrfx-auth library.
This module provides a complete CSRF‑protected authentication solution for web scraping, testing, and automation. It includes:
AuthError
The library reads configuration from a .env file (or environment variables) and automatically caches sessions in ~/.cache/libts-csrfx-auth/session.json.
.env
~/.cache/libts-csrfx-auth/session.json
// Basic login with environment variablesimport { AuthClient } from 'libts-csrfx-auth';const auth = new AuthClient();const session = await auth.login();console.log('Logged in, CSRF token:', session.csrfToken); Copy
// Basic login with environment variablesimport { AuthClient } from 'libts-csrfx-auth';const auth = new AuthClient();const session = await auth.login();console.log('Logged in, CSRF token:', session.csrfToken);
// Check cached session before logging inif (await auth.hasValidSession()) { const session = await auth.getCachedSession(); // reuse session...} else { await auth.login();} Copy
// Check cached session before logging inif (await auth.hasValidSession()) { const session = await auth.getCachedSession(); // reuse session...} else { await auth.login();}
// Logoutimport { LogoutClient } from 'libts-csrfx-auth';const logout = new LogoutClient();await logout.logout();@packageDocumentation Copy
// Logoutimport { LogoutClient } from 'libts-csrfx-auth';const logout = new LogoutClient();await logout.logout();@packageDocumentation
Fileoverview
Main entry point for the libts-csrfx-auth library.
This module provides a complete CSRF‑protected authentication solution for
web scraping, testing, and automation. It includes:
AuthErrorwith retry and authentication helpersThe library reads configuration from a
.envfile (or environment variables)and automatically caches sessions in
~/.cache/libts-csrfx-auth/session.json.Example
Example
Example