Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions __tests__/non-esm-import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "non-esm-import",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
4 changes: 4 additions & 0 deletions __tests__/non-esm-import/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(async () => {
const {RadiusServer} = await import('../../dist/index.js');
console.log('RADIUSServer', RadiusServer);
})();
4 changes: 2 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NodeCache from 'node-cache';
import { Cache, ExpirationStrategy, MemoryStorage } from '@hokify/node-ts-cache';
import { IAuthentication } from './interfaces/Authentication';
import { ILogger } from './interfaces/Logger';
import { IAuthentication } from './interfaces/Authentication.js';
import { ILogger } from './interfaces/Logger.js';

const cacheStrategy = new ExpirationStrategy(new MemoryStorage());
/**
Expand Down
4 changes: 2 additions & 2 deletions src/auth/GoogleLDAPAuth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ldapjs, { ClientOptions } from 'ldapjs';
import * as tls from 'tls';
import * as fs from 'fs';
import { IAuthentication } from '../interfaces/Authentication';
import { ILogger } from '../interfaces/Logger';
import { IAuthentication } from '../interfaces/Authentication.js';
import { ILogger } from '../interfaces/Logger.js';

const usernameFields = ['posixUid', 'mail'];

Expand Down
4 changes: 2 additions & 2 deletions src/auth/HTTPAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from 'node-fetch';
import { IAuthentication } from '../interfaces/Authentication';
import { ILogger } from '../interfaces/Logger';
import { IAuthentication } from '../interfaces/Authentication.js';
import { ILogger } from '../interfaces/Logger.js';

interface IHTTPAuthOptions {
url: string;
Expand Down
4 changes: 2 additions & 2 deletions src/auth/IMAPAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as imaps from 'imap-simple';
import { IAuthentication } from '../interfaces/Authentication';
import { ILogger } from '../interfaces/Logger';
import { IAuthentication } from '../interfaces/Authentication.js';
import { ILogger } from '../interfaces/Logger.js';

interface IIMAPAuthOptions {
host: string;
Expand Down
4 changes: 2 additions & 2 deletions src/auth/LDAPAuth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as LdapAuth from 'ldapauth-fork';
import * as fs from 'fs';
import { IAuthentication } from '../interfaces/Authentication';
import { ILogger } from '../interfaces/Logger';
import { IAuthentication } from '../interfaces/Authentication.js';
import { ILogger } from '../interfaces/Logger.js';

interface ILDAPAuthOptions {
/** ldap url
Expand Down
4 changes: 2 additions & 2 deletions src/auth/SMTPAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SMTPClient } from 'smtp-client';
import { IAuthentication } from '../interfaces/Authentication';
import { ILogger } from '../interfaces/Logger';
import { IAuthentication } from '../interfaces/Authentication.js';
import { ILogger } from '../interfaces/Logger.js';

interface ISMTPAuthOptions {
host: string;
Expand Down
4 changes: 2 additions & 2 deletions src/auth/StaticAuth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IAuthentication } from '../interfaces/Authentication';
import { ILogger } from '../interfaces/Logger';
import { IAuthentication } from '../interfaces/Authentication.js';
import { ILogger } from '../interfaces/Logger.js';

interface IStaticAuthOtions {
validCredentials: {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IAuthentication } from './interfaces/Authentication';
import { RadiusServerOptions } from './interfaces/RadiusServerOptions';
import { RadiusServer } from './radius/RadiusServer';
import { IAuthentication } from './interfaces/Authentication.js';
import { RadiusServerOptions } from './interfaces/RadiusServerOptions.js';
import { RadiusServer } from './radius/RadiusServer.js';

export { IAuthentication as RadiusAuthentication, RadiusServerOptions, RadiusServer };

Expand Down
20 changes: 19 additions & 1 deletion src/interfaces/EAPMethod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import { IPacket, IPacketHandlerResult } from './PacketHandler';
import { IPacket, IPacketHandlerResult } from './PacketHandler.js';

export enum EAPRequestType {
REQUEST = 1,
RESPONSE = 2,
SUCCESS = 3,
FAILURE = 4,
}

export enum EAPMessageType {
IDENTIFY = 1,
NOTIFICATION = 2,
NAK = 3,
MD5 = 4,
GTC = 6,
TTLS = 21,
PEAP = 25,
EXPANDED = 254,
}

export interface IEAPMethod {
getEAPType(): number;
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/RadiusServerOptions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SecureContextOptions } from 'tls';
import { IAuthentication } from './Authentication';
import { ILogger } from './Logger';
import { LogLevel } from '../logger/ConsoleLogger';
import { IAuthentication } from './Authentication.js';
import { ILogger } from './Logger.js';
import { LogLevel } from '../logger/ConsoleLogger.js';

export type RadiusServerOptions = IRadiusServerOptions &
(
Expand Down
2 changes: 1 addition & 1 deletion src/logger/ConsoleLogger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ILogger } from '../interfaces/Logger';
import { ILogger } from '../interfaces/Logger.js';

export enum LogLevel {
Verbose = 'verbose',
Expand Down
3 changes: 2 additions & 1 deletion src/radius/handler/eap/EAPHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IPacketHandlerResult, PacketResponseCode } from '../../../interfaces/PacketHandler.js';
import { EAPMessageType } from '../../../interfaces/EAPMethod.js';

export function buildEAP(identifier: number, msgType: number, data?: Buffer) {
export function buildEAP(identifier: number, msgType: EAPMessageType, data?: Buffer) {
/** build a package according to this:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Expand Down
8 changes: 4 additions & 4 deletions src/radius/handler/eap/eapMethods/EAP-TTLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
PacketResponseCode,
} from '../../../../interfaces/PacketHandler.js';
import { MAX_RADIUS_ATTRIBUTE_SIZE, newDeferredPromise } from '../../../../helpers.js';
import { IEAPMethod } from '../../../../interfaces/EAPMethod.js';
import { EAPMessageType, IEAPMethod } from '../../../../interfaces/EAPMethod.js';
import { IAuthentication } from '../../../../interfaces/Authentication.js';
import { ILogger } from '../../../../interfaces/Logger.js';

Expand Down Expand Up @@ -46,7 +46,7 @@ export class EAPTTLS implements IEAPMethod {
private openTLSSockets = new NodeCache({ useClones: false, stdTTL: 3600 }); // keep sockets for about one hour

getEAPType(): number {
return 21;
return EAPMessageType.TTLS;
}

identify(identifier: number, stateID: string): IPacketHandlerResult {
Expand Down Expand Up @@ -79,7 +79,7 @@ export class EAPTTLS implements IEAPMethod {

private buildEAPTTLS(
identifier: number,
msgType = 21,
msgType = EAPMessageType.TTLS,
msgFlags = 0x00,
stateID: string,
data?: Buffer,
Expand Down Expand Up @@ -163,7 +163,7 @@ export class EAPTTLS implements IEAPMethod {

private buildEAPTTLSResponse(
identifier: number,
msgType = 21,
msgType = EAPMessageType.TTLS,
msgFlags = 0x00,
stateID: string,
data?: Buffer,
Expand Down