Files
..

@push.rocks/smartradius/shared

📡 RADIUS Protocol Definitions - Shared types and enums for RFC 2865/2866 compliance

Overview

This module contains the core RADIUS protocol definitions shared between the server and client implementations. It provides all the RFC 2865 (Authentication) and RFC 2866 (Accounting) enums and interfaces that represent the RADIUS protocol.

Contents

Enums (enums.ts)

All RFC-compliant protocol constants:

Enum Description RFC Reference
ERadiusCode Packet types (Access-Request, Access-Accept, etc.) RFC 2865 §3
ERadiusAttributeType Standard attribute types (1-63, 79-80) RFC 2865 §5
EServiceType Service-Type attribute values RFC 2865 §5.6
EFramedProtocol Framed-Protocol values RFC 2865 §5.7
EFramedRouting Framed-Routing values RFC 2865 §5.10
EFramedCompression Framed-Compression values RFC 2865 §5.13
ELoginService Login-Service values RFC 2865 §5.15
ETerminationAction Termination-Action values RFC 2865 §5.29
ENasPortType NAS-Port-Type values RFC 2865 §5.41
EAcctStatusType Acct-Status-Type values RFC 2866 §5.1
EAcctAuthentic Acct-Authentic values RFC 2866 §5.6
EAcctTerminateCause Acct-Terminate-Cause values RFC 2866 §5.10

Interfaces (interfaces.ts)

Core data structures representing RADIUS protocol elements:

Interface Description
TAttributeValueType Value type union ('text', 'string', 'address', 'integer', 'time', 'vsa')
IAttributeDefinition Attribute metadata (type, name, valueType, encrypted)
IRadiusAttribute Raw TLV (type-length-value) format
IParsedAttribute Parsed attribute with name and decoded value
IVendorSpecificAttribute VSA format (vendorId, vendorType, vendorValue)
IRadiusPacket Packet structure (code, identifier, authenticator, attributes)
IParsedRadiusPacket Packet with parsed attributes

Usage

import {
  ERadiusCode,
  ERadiusAttributeType,
  EAcctStatusType,
  IRadiusPacket,
  IParsedAttribute,
} from '@push.rocks/smartradius';

// Check packet type
if (packet.code === ERadiusCode.AccessRequest) {
  // Handle authentication request
}

// Check accounting status
if (request.statusType === EAcctStatusType.Start) {
  // Session started
}

// Access attribute by type
const username = packet.attributes.find(
  a => a.type === ERadiusAttributeType.UserName
);

Why a Shared Module?

This module provides clear separation between:

  • Protocol definitions (what RADIUS is) - lives here
  • Server implementation (how to serve RADIUS) - lives in ts_server
  • Client implementation (how to consume RADIUS) - lives in ts_client

This separation provides:

  • 🎯 Better semantic clarity for API consumers
  • 📦 Smaller imports when only types are needed
  • 🔄 Clean dependency graph (shared → server/client → main)