Registry / http-networking / httpntlm

httpntlm

JSON →
library1.8.13jsnpmunverified

httpntlm is a Node.js library designed to facilitate HTTP NTLM authentication, a protocol used in Windows environments. It is a direct port of the Python `python-ntlm` library and notably includes support for NTLMv2, which handles extended security and target information negotiations. The current stable version is 1.8.13, and while it's a mature library with over a decade of history, its release cadence appears infrequent, with the last significant README update in March 2023. Key differentiators include its focused implementation of NTLM for Node.js, offering both a high-level API for common use cases (GET, POST, etc.) and granular access to NTLM message creation and parsing for advanced scenarios. It supports both HTTP and HTTPS connections, and allows for pre-encrypting passwords for enhanced security. The library relies on other modules like `httpreq`, `async`, and `agentkeepalive` for its underlying HTTP requests and flow control.

npm install httpntlm
INSTALL
IMPORT
SIG · HTTPNTLM
H
httpntlm
http-networkingjavascriptv1.8.13
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.

httpntlm
const httpntlm = require('httpntlm');
import httpntlm from 'httpntlm';
This package is primarily CommonJS. Direct `import` syntax will likely result in an error in pure ESM environments without specific Node.js configuration or bundler setup.
httpntlm.get
const httpntlm = require('httpntlm'); httpntlm.get({ /* options */ }, callback);
The primary method for performing NTLM-authenticated GET requests. Similar methods (post, put, del) are also available.
httpntlm.ntlm
const { ntlm } = require('httpntlm'); // or const ntlm = require('httpntlm').ntlm;
import { ntlm } from 'httpntlm';
Provides access to the raw NTLM message creation and parsing functions (e.g., `createType1Message`, `parseType2Message`, `create_LM_hashed_password`), intended for advanced scenarios where manual control over the NTLM handshake is required.

Demonstrates how to perform a basic NTLM-authenticated GET request using the library's high-level API, including error handling and using environment variables for sensitive credentials.

const httpntlm = require('httpntlm'); httpntlm.get({ url: "https://someurl.com", // Replace with your NTLM-protected URL username: process.env.NTLM_USERNAME ?? '', password: process.env.NTLM_PASSWORD ?? '', workstation: process.env.NTLM_WORKSTATION ?? 'local_workstation', domain: process.env.NTLM_DOMAIN ?? '' }, function (err, res){ if(err) { console.error("NTLM GET request failed:", err.message); // Log the error message return; } console.log("Status Code:", res.statusCode); console.log("Response Headers:", res.headers); console.log("Response Body (truncated):"); console.log(res.body ? res.body.substring(0, 500) + '...' : '[No Body]'); // Truncate body for readability });
Debug
Known issues
gotchaThe library explicitly states that it assumes the server supports NTLMv2 and creates responses accordingly. If the server only supports NTLMv1 and does not negotiate NTLMv2 extended security, this assumption might lead to authentication failures or unexpected behavior.
fix
Ensure the target server supports NTLMv2. If NTLMv1 is strictly required, manual NTLM message handling via `httpntlm.ntlm` might be necessary, or consider alternative libraries that allow explicit NTLM version specification.
affects: >=1.0.0
deprecatedThe package's specified Node.js engine requirement is `>=10.4.0`, a very old version of Node.js. While the library might function on newer Node.js versions, official support and compatibility testing beyond Node.js 10 may be limited, potentially leading to unforeseen issues.
fix
Exercise caution when using in modern Node.js environments. Monitor for compatibility issues and consider alternative, actively maintained NTLM solutions if stability becomes a concern.
affects: <=1.8.13
breakingThe package is primarily CommonJS (CJS). Attempting to `import` it directly in a pure ECMAScript Module (ESM) Node.js project (e.g., with `"type": "module"` in `package.json`) will result in a `TypeError: require is not a function` or similar module resolution errors.
fix
For ESM projects, use dynamic `await import('httpntlm')` or ensure your build process correctly transpiles or bundles CJS dependencies. Alternatively, switch your project to CommonJS if `httpntlm` is a critical dependency and ESM is not strictly required.
affects: >=1.0.0
gotchaThe Snyk security scan badge in the README indicates 'Known Vulnerabilities'. While the Snyk Vulnerability Database currently shows no *direct* vulnerabilities for `httpntlm` itself, it's crucial to check its *dependencies* for vulnerabilities which may be indirectly introduced.
fix
Regularly scan your project's dependencies using tools like Snyk, npm audit, or yarn audit to identify and mitigate any transitive vulnerabilities introduced by `httpntlm` or its components. Update dependencies as recommended.
affects: *
Errors
Common errors & fixes
www-authenticate not found on response of second request
During the NTLM handshake, the server must respond with a `WWW-Authenticate` header containing the Type 2 challenge message. This error indicates the server did not provide the expected challenge, likely due to an invalid initial Type 1 message or incorrect server configuration.
fix
Verify the URL, username, password, workstation, and domain are correct. Ensure the server endpoint is indeed NTLM-protected and configured correctly. Debug the initial Type 1 message sent to confirm it's well-formed.
NTLM authentication failed: Invalid credentials
This is a generic authentication failure, usually stemming from incorrect `username`, `password`, `workstation`, or `domain` parameters. It can also occur if the NTLM hashes generated are incorrect.
fix
Double-check all authentication parameters for typos or incorrect values. Ensure the user account has access to the resource. If pre-encrypting passwords, verify the `lm_password` and `nt_password` buffers are generated correctly from the plaintext password. Consider setting `domain` to an empty string if unsure.
TypeError: require is not a function
This error occurs when attempting to use `require()` syntax in an ECMAScript Module (ESM) context. The `httpntlm` library is designed for CommonJS.
fix
If your project is ESM, either switch to dynamic `await import('httpntlm')` (if supported and appropriate for your use case) or configure your build system to handle CommonJS modules. If possible, consider setting `"type": "commonjs"` in your `package.json` or changing file extensions to `.cjs` for files that use `require()`.
Upgrade
Version history
1.8.13latest on npm
Audit
Dependencies
httpreqrequiredUsed internally for making HTTP requests; exposes its options to httpntlm's API.
asyncoptionalUtilized in advanced usage patterns for flow control, particularly when manually handling NTLM steps.
agentkeepaliveoptionalProvides an `HttpsAgent` for connection pooling, improving performance for multiple requests.
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
httpntlm — npm install httpntlm · libregistry