Registry / http-networking / node-radius-utils

node-radius-utils

JSON →
library1.2.0jsnpmunverified

node-radius-utils is a utility package designed to simplify working with RADIUS protocols in Node.js environments. It provides comprehensive access to FreeRADIUS server dictionary files, including all standard dictionaries like RFC2865, as well as vendor-specific ones like Nokia. The library is currently at version 1.2.0, indicating a stable release without frequent breaking changes. It offers typed locations for dictionary files, typed attributes, and typed values, significantly enhancing the developer experience, especially for TypeScript users. A key feature is the `attributesToArray` utility function, which facilitates converting a plain JavaScript object of RADIUS attributes into the specific array-of-arrays format required by libraries such as `node-radius`. While no explicit release cadence is documented, typical open-source practices suggest bug fixes via patch versions and new features via minor versions. Its primary differentiator is the pre-packaged and highly typed dictionary definitions, saving developers from the laborious task of manually parsing or maintaining these complex configuration files. It is explicitly designed to be used as a companion to a full-fledged RADIUS protocol implementation like `node-radius`, rather than being a standalone client or server.

npm install node-radius-utils
INSTALL
IMPORT
SIG · NODE-RADIUS-UTILS
N
node-radius-utils
http-networkingjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dictionaries
import { dictionaries } from 'node-radius-utils';
import { rfc2865 } from 'node-radius-utils';
The various dictionary objects (e.g., `rfc2865`, `nokia`) are nested within the top-level `dictionaries` export. You must import `dictionaries` first, then access its properties. The `wrong` example attempts to directly import a nested dictionary.
attributesToArray
import { attributesToArray } from 'node-radius-utils';
import attributesToArray from 'node-radius-utils';
This is a named export. Ensure you use destructuring to import it correctly, and not as a default import. The `wrong` example shows an incorrect attempt to import it as a default export.
PACKET_TYPE (nested)
import { dictionaries } from 'node-radius-utils'; const { values: { PACKET_TYPE } } = dictionaries.freeradius_internal;
import { PACKET_TYPE } from 'node-radius-utils';
Packet types are nested deeply within specific dictionary `values` objects (e.g., `dictionaries.freeradius_internal.values.PACKET_TYPE`). They are not top-level exports and must be accessed via their parent dictionary object.

Demonstrates importing dictionary files and the `attributesToArray` utility, then using them with the `radius` library to encode a RADIUS Access-Request packet with various attributes.

import radius from 'radius'; // npm i radius import { dictionaries: { all, rfc2865, nokia, freeradius_internal, }, attributesToArray, } from 'node-radius-utils'; // Use the default dictionary which includes all dictionary files. // Resolves to node_modules/radius-utils/dictionaries/default radius.add_dictionary(all.file); // Use a specific dictionary // Resolves to node_modules/radius-utils/dictionaries/dictionary.rfc2865 radius.add_dictionary(rfc2865.file); // Use a specific dictionary // Resolves to node_modules/radius-utils/dictionaries/dictionary.nokia radius.add_dictionary(nokia.file); const { values: { PACKET_TYPE } } = freeradius_internal; // Example of encoding a RADIUS packet const encodedPacket = radius.encode({ code: PACKET_TYPE.ACCESS_REQUEST, // resolves to Access-Request secret: 'super-secret', attributes: attributesToArray({ // resolves to Nas-Ip-Address [rfc2865.attributes.NAS_IP_ADDRESS]: '192,168.1.123', // resolves to User-Name [rfc2865.attributes.USER_NAME]: 'bob', // resolves to User-Password [rfc2865.attributes.USER_PASSWORD]: 'hunter2', // resolves to Calling-Station-Id [rfc2865.attributes.CALLING_STATION_ID]: 'AA:BB:CC:DD:EE:FF', // resloves to Nokia-Service-Name [nokia.attributes.NOKIA_SERVICE_NAME]: 'SuperService', }), }); console.log('Encoded RADIUS packet:', encodedPacket);
Debug
Known issues
gotchaThis library provides RADIUS dictionary utilities only. It does NOT implement a RADIUS client or server. You must use a separate library, such as `node-radius`, for actual RADIUS packet encoding, decoding, and communication. This is a common misunderstanding where users expect full RADIUS functionality from this utility package.
fix
Ensure you install and configure a RADIUS protocol implementation like `npm i radius` alongside `node-radius-utils`.
affects: >=1.0.0
gotchaThe dictionary files are resolved relative to `node_modules` paths. If you're running in environments with non-standard module resolution or using bundlers that don't handle dynamic `require` or `import.meta.url` paths well, you might encounter issues loading the dictionary files.
fix
Verify that your module bundler (e.g., Webpack, Rollup, Parcel) is configured to correctly resolve Node.js module paths for dynamically loaded files, or consider manually passing file paths if bundling fails.
affects: >=1.0.0
gotchaAttribute and value names are typically uppercase constants (e.g., `NAS_IP_ADDRESS`, `ACCESS_REQUEST`). Attempting to use incorrect casing or non-existent attributes will lead to `undefined` values or errors when encoding/decoding, as these are strict lookups based on dictionary definitions.
fix
Always refer to the typed exports (e.g., `rfc2865.attributes.NAS_IP_ADDRESS`) or the library's documentation for the correct casing and availability of attributes and values. TypeScript users will benefit from autocomplete and type checking for these exports.
affects: >=1.0.0
breakingWhile not explicitly stated for minor versions, future major versions of `node-radius-utils` might introduce changes to the structure of the `dictionaries` object or the `attributesToArray` function signature to adapt to evolving FreeRADIUS dictionaries or API improvements. This could require code changes upon upgrade.
fix
When upgrading to a new major version, always carefully review the changelog and any migration guides for breaking changes related to dictionary access or utility function usage.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: radius.add_dictionary is not a function
The `radius` library (e.g., `node-radius`) was not installed, incorrectly imported, or an incompatible version is being used. `node-radius-utils` does not provide `radius` client/server functionality.
fix
Ensure `npm install radius` has been run and that the `radius` object is correctly imported and available at runtime. Verify compatibility between `node-radius` and `node-radius-utils` versions.
TypeError: Cannot read properties of undefined (reading 'attributes')
Attempting to access attributes from a dictionary that doesn't exist or was not correctly imported from `node-radius-utils.dictionaries` (e.g., `dictionaries.nonexistent.attributes`).
fix
Verify the dictionary name you are trying to access (e.g., `rfc2865`, `nokia`, `freeradius_internal`) is a valid and correctly spelled export from `node-radius-utils.dictionaries` and that it was properly destructured.
Error: Unknown attribute 'Nokia-Service-Name' (or similar error from `node-radius` upon encoding)
An attribute was passed to `attributesToArray` or directly to `radius.encode` that is not defined in the dictionaries currently loaded by the `radius` library, or the wrong dictionary file was added to `node-radius`.
fix
Ensure all necessary dictionary files (e.g., `nokia.file`) have been added to the `radius` library using `radius.add_dictionary()`. Also, verify the attribute key used in `attributesToArray` (e.g., `nokia.attributes.NOKIA_SERVICE_NAME`) correctly maps to an attribute defined in the loaded dictionaries and is case-sensitive.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
radiusrequiredRequired for encoding/decoding RADIUS packets, as this library only provides dictionary utilities.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
node-radius-utils — npm install node-radius-utils · libregistry