Registry / auth-security / saslmechanisms

saslmechanisms

JSON →
library0.1.1jsnpmunverified

saslmechanisms is a foundational JavaScript framework designed to facilitate SASL (Simple Authentication and Security Layer) authentication and data security within connection-oriented protocols. Released as version 0.1.1 over a decade ago, it provides a `Factory` pattern for managing and negotiating pluggable SASL mechanisms. The package itself does not include any authentication mechanisms; instead, it serves as an extensible core that requires separate, dedicated packages (e.g., `sasl-plain`) to implement specific SASL methods. Due to its age and lack of updates, it is largely superseded by more modern authentication solutions and is not actively maintained, making its current utility limited outside of legacy systems. The framework's primary differentiator was its modularity, allowing developers to easily extend supported authentication types by plugging in new mechanism implementations.

npm install saslmechanisms
INSTALL
IMPORT
SIG · SASLMECHANISMS
S
saslmechanisms
auth-securityjavascriptv0.1.1
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.

Factory
const sasl = require('saslmechanisms'); const factory = new sasl.Factory();
import { Factory } from 'saslmechanisms';
The package exports an object (often aliased as `sasl`) that contains the `Factory` constructor. This package is CommonJS-only; ESM imports are not supported.
Mechanism registration
factory.use(require('sasl-plain'));
factory.use(SASLPlain);
Mechanism packages like `sasl-plain` are expected to be `require()`-d directly and passed to the `use` method to register them with the factory. Ensure the mechanism package is installed.
ClientSession / ServerSession
const clientSession = factory.createClientSession('PLAIN');
const clientSession = new sasl.ClientSession('PLAIN');
Client and server sessions are instantiated via the `factory` instance after mechanisms have been registered, not directly from the `sasl` object.

Demonstrates initializing the SASL factory, registering the 'PLAIN' mechanism, and simulating a basic client-server authentication flow.

const sasl = require('saslmechanisms'); // Create a SASL mechanism factory. const factory = new sasl.Factory(); // Register supported SASL mechanisms. This package only provides the framework; // mechanism implementations like 'sasl-plain' must be installed separately. // For this example, ensure 'sasl-plain' is installed: npm install sasl-plain try { factory.use(require('sasl-plain')); console.log('SASL PLAIN mechanism registered successfully.'); } catch (e) { console.error('Failed to load sasl-plain. Make sure it is installed: npm install sasl-plain'); process.exit(1); } // Simulate client and server interactions for 'PLAIN' authentication. const username = process.env.SASL_USERNAME || 'testuser'; const password = process.env.SASL_PASSWORD || 'testpassword'; // Client-side: initiate authentication with credentials const clientSession = factory.createClientSession('PLAIN'); // 'PLAIN' is the mechanism name const initialClientChallenge = clientSession.challenge({ username: username, password: password }); console.log(`\nClient initiated authentication with challenge: "${initialClientChallenge}"`); // Server-side: respond to the client's challenge const serverSession = factory.createServerSession('PLAIN'); try { const serverResponse = serverSession.response(initialClientChallenge); if (serverSession.isComplete()) { console.log('Server successfully completed authentication.'); console.log(`Authenticated user: ${serverSession.username}`); // In PLAIN, serverResponse is typically an empty string on success } else { console.log('Server authentication not complete, further steps might be required.'); } } catch (error) { console.error(`Server failed to authenticate: ${error.message}`); } console.log('\nSASL framework demonstration complete.');
Debug
Known issues
breakingThis package is extremely old (v0.1.1, published over a decade ago) and has been abandoned. It is highly unlikely to be compatible with modern Node.js versions or maintain current security standards. Using it in new projects is strongly discouraged.
fix
Consider modern alternatives for authentication, such as OAuth2, OpenID Connect, or actively maintained SASL libraries if strict SASL compliance is necessary.
affects: >=0.1.1
gotchaThe package is CommonJS-only and does not support ES Modules (`import`). Attempting to use `import` syntax will result in errors.
fix
Always use `require()` for importing the `saslmechanisms` package and any associated mechanism packages.
affects: >=0.1.1
gotchaThe `saslmechanisms` package provides only the framework; actual SASL authentication mechanisms (e.g., PLAIN, DIGEST-MD5) must be installed as separate npm packages (e.g., `sasl-plain`, `sasl-digest-md5`) and registered with the factory.
fix
Ensure all required `sasl-*` mechanism packages are explicitly installed via npm and registered using `factory.use(require('sasl-mechanism-package'));`
affects: >=0.1.1
deprecatedThe `volo` package manager mentioned in the README for installation (`volo add jaredhanson/js-sasl sasl`) is obsolete and no longer maintained. Use npm for package installation.
fix
Install using npm: `npm install saslmechanisms`.
affects: >=0.1.1
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'Factory')
The `saslmechanisms` package was not correctly `require()`-d, or the variable name does not match the expected export.
fix
Ensure you are using `const sasl = require('saslmechanisms');` and then `new sasl.Factory();`.
Error: Unknown mechanism "PLAIN"
The required SASL mechanism package (e.g., `sasl-plain`) was not installed or not correctly registered with the factory using `factory.use()`.
fix
Install the necessary mechanism package (e.g., `npm install sasl-plain`) and add `factory.use(require('sasl-plain'));` to your initialization code.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
sasl-plainoptionalCommon SASL mechanism, required at runtime for 'PLAIN' authentication. Other `sasl-*` mechanism packages are also runtime dependencies depending on desired authentication methods.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
saslmechanisms — npm install saslmechanisms · libregistry