94 lines
2.1 KiB
Markdown
94 lines
2.1 KiB
Markdown
# @push.rocks/smartradius
|
|
|
|
> 🔐 Complete RADIUS Server and Client Library for Node.js
|
|
|
|
## Overview
|
|
|
|
This is the main entry point for the smartradius library. It re-exports all functionality from the server, client, and shared modules, providing a unified API for RADIUS operations.
|
|
|
|
## What Gets Exported
|
|
|
|
This module combines exports from:
|
|
|
|
- **ts_shared** - Protocol definitions, enums, and core interfaces
|
|
- **ts_server** - Server implementation and utilities
|
|
- **ts_client** - Client implementation
|
|
|
|
## Quick Import
|
|
|
|
```typescript
|
|
// Everything from one import
|
|
import {
|
|
// Server
|
|
RadiusServer,
|
|
RadiusPacket,
|
|
RadiusAttributes,
|
|
RadiusAuthenticator,
|
|
|
|
// Client
|
|
RadiusClient,
|
|
|
|
// Shared Enums
|
|
ERadiusCode,
|
|
ERadiusAttributeType,
|
|
EAcctStatusType,
|
|
EAcctTerminateCause,
|
|
|
|
// Shared Interfaces
|
|
IRadiusPacket,
|
|
IParsedAttribute,
|
|
|
|
// Server Interfaces
|
|
IRadiusServerOptions,
|
|
IAuthenticationRequest,
|
|
IAuthenticationResponse,
|
|
|
|
// Client Interfaces
|
|
IRadiusClientOptions,
|
|
IClientAuthRequest,
|
|
IClientAuthResponse,
|
|
} from '@push.rocks/smartradius';
|
|
```
|
|
|
|
## Sub-modules
|
|
|
|
For more targeted imports, see the individual module documentation:
|
|
|
|
| Module | Description |
|
|
|--------|-------------|
|
|
| [ts_shared](../ts_shared/readme.md) | Protocol definitions and enums |
|
|
| [ts_server](../ts_server/readme.md) | Server implementation |
|
|
| [ts_client](../ts_client/readme.md) | Client implementation |
|
|
|
|
## Usage Example
|
|
|
|
```typescript
|
|
import { RadiusServer, RadiusClient, ERadiusCode } from '@push.rocks/smartradius';
|
|
|
|
// Create server
|
|
const server = new RadiusServer({
|
|
defaultSecret: 'testing123',
|
|
authenticationHandler: async (req) => ({
|
|
code: req.password === 'secret'
|
|
? ERadiusCode.AccessAccept
|
|
: ERadiusCode.AccessReject
|
|
}),
|
|
});
|
|
await server.start();
|
|
|
|
// Create client
|
|
const client = new RadiusClient({
|
|
host: '127.0.0.1',
|
|
secret: 'testing123',
|
|
});
|
|
await client.connect();
|
|
|
|
// Authenticate
|
|
const result = await client.authenticatePap('user', 'secret');
|
|
console.log('Accepted:', result.accepted);
|
|
|
|
// Cleanup
|
|
await client.disconnect();
|
|
await server.stop();
|
|
```
|