@tty-pt/axil-auth logo

@tty-pt/axil-auth

npm version License: BSD-2-Clause TypeScript Ready Node.js Native Authentication

Session management, user registration, credential verification, and terminal access gating for @tty-pt/axil. Canonical C headers: <ttypt/auth.h>, <ttypt/auth-config.h>, and <ttypt/auth-outcome.h>.

๐Ÿ“– Full C & Systems Documentation: See the main axil-auth GitHub README for HTTP endpoint contracts, multi-instance cookie isolation, and C module integration.


1. Overview & Domain Concepts

axil-auth (libaxil-auth.so / @tty-pt/axil-auth) provides complete HTTP authentication and session lifecycle management for the axil web server and Node.js applications:

  1. HTTP Authentication Lifecycle:
  1. Multi-Instance Session Cookie Isolation:
  1. Structured Outcome Codes (<ttypt/auth-outcome.h>):
  1. POSIX & Terminal Gating Integration:

2. Installation

npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/axil-auth

Native OS & Mobile Packages (tty.pt): Prebuilt native C packages (axil-auth) for Linux (apt, apk, pacman, dnf), macOS (brew), Windows (winget, MSYS2), and OpenBSD (pkg_add), plus static mobile sysroots for Android (https://tty.pt/android/) and iOS (https://tty.pt/ios/ โ€” libaxil-auth.xcframework) are available via the tty.pt package repositories.


3. Quickstart

Launch axil with Authentication Enabled

npx axil -d -p 8080 -m auth

Node.js Session & Credential Verification

import {
  configure,
  initAuth,
  extractCookie,
  getSessionUser,
  verifyPassword,
  usernameTaken,
  getConfig,
  getModulePath
} from "@tty-pt/axil-auth";

// 1. Configure session TTL and directories
configure({
  cookieName: "QSESSION",
  sessionTtl: 86400,
  routePrefix: "/auth"
});
initAuth();

// 2. Extract session token from HTTP Cookie header and resolve user
const token = extractCookie("QSESSION=8f9a2b3c4d5e; Path=/");
const user = token ? getSessionUser(token) : null;
console.log("Authenticated user:", user);

// 3. Check username availability & verify password
if (usernameTaken("alice")) {
  const ok = verifyPassword("alice", "CorrectHorseBatteryStaple!");
  console.log("Password valid:", ok);
}

console.log("Active config:", getConfig());
console.log("Bundled Xylem module:", getModulePath());

4. JavaScript / TypeScript API Reference


5. C Development Headers & Native Integration

CFLAGS += -I./node_modules/@tty-pt/axil-auth/include
LDLIBS += -laxil-auth

License

BSD-2-Clause โ€” Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.

Documentation