CSRF-X Auth Library - v1.0.3
    Preparing search index...

      CSRF-X Auth Library - v1.0.3

      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:

      • AuthClient: Two‑step login (GET for CSRF token, POST with credentials)
      • LogoutClient: Session termination with CSRF token
      • CacheManager: Persistent session storage on disk
      • Error handling: Typed AuthError with retry and authentication helpers
      • Utilities: Cookie parsing, CSRF extraction, HTTP retries, session helpers

      The library reads configuration from a .env file (or environment variables)
      and automatically caches sessions in ~/.cache/libts-csrfx-auth/session.json.

      // Basic login with environment variables
      import { 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 in
      if (await auth.hasValidSession()) {
      const session = await auth.getCachedSession();
      // reuse session...
      } else {
      await auth.login();
      }
      // Logout
      import { LogoutClient } from 'libts-csrfx-auth';

      const logout = new LogoutClient();
      await logout.logout();

      @packageDocumentation

      Functions

      loadEnv
      isRetryableError
      isAuthenticationError
      isAuthError
      buildInfo
      parseCookies
      buildCookieHeader
      parseSetCookie
      extractCsrfToken
      fetchWithRetry
      sessionWithCsrfToken
      isSessionFresh

      Classes

      AuthClient
      LogoutClient
      EnvConfig
      AuthError
      CacheManager

      Interfaces

      LoginOptions
      LogoutOptions
      EnvConfigOptions
      EnvVars
      FetchOptions
      SessionData

      Type Aliases

      AuthErrorCode

      Variables

      AuthErrorCode
      VERSION
      NAME

      References

      AuthErrorCodeType → AuthErrorCode