Registry / http-networking / indigestion

indigestion

JSON →
library0.03jsnpmunverified

Indigestion is a focused Node.js library designed to generate HTTP Digest Authentication strings. It specifically takes the `WWW-Authenticate` header from a 401 response and provides the `Authorization` header content. The current stable version is v0.4.0, with releases appearing to be on-demand for maintenance or minor feature additions rather than a strict schedule, as indicated by the most recent release in February 2026. This library differentiates itself from other digest authentication solutions (like `axios-digest` or `node-digest-auth-client`) by offering only the header generation functionality, allowing developers full control over the HTTP request client and lifecycle. It aims to fill a niche where only the calculated `Digest` header string is needed, without the library dictating how the actual HTTP request is made.

npm install indigestion
INSTALL
IMPORT
SIG · INDIGESTION
I
indigestion
http-networkingjavascriptv0.03
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.

generateDigestAuth
import { generateDigestAuth } from 'indigestion';
import indigestion = require('indigestion'); const digest = indigestion.generateDigestAuth(...);
While the README shows `import indigestion = require("indigestion");`, which is a TypeScript CJS-style import, modern TypeScript and ESM usage prefers named imports. The package ships TypeScript types and supports both.
findNonceCount
import { findNonceCount } from 'indigestion';
const findNonceCount = require('indigestion').findNonceCount;
Utility function for parsing the nonce count from an existing Digest header. Follows standard named import patterns.

This quickstart demonstrates a typical Digest Authentication flow using `axios` and `indigestion`. It first attempts a request, catches a 401 response, extracts the `WWW-Authenticate` header, generates the `Authorization` header using `generateDigestAuth`, and then retries the request with the generated header.

import axios from "axios"; import { generateDigestAuth } from 'indigestion'; async function makeDigestAuthenticatedRequest() { const username = process.env.DIGEST_USERNAME ?? 'testuser'; const password = process.env.DIGEST_PASSWORD ?? 'testpass'; const targetUrl = 'http://www.example.com/protected/resource'; // Replace with your target URL const method = 'GET'; try { // First attempt: Expect a 401 Unauthorized response await axios.get(targetUrl); } catch (error: any) { if (error.response && error.response.status === 401) { const authenticateHeader = error.response.headers['www-authenticate']; if (!authenticateHeader) { throw new Error('WWW-Authenticate header not found in 401 response.'); } // Generate the Digest Authorization header const authorizationHeader = generateDigestAuth({ authenticateHeader, username, password, uri: new URL(targetUrl).pathname, method }); // Retry the request with the generated Authorization header const result = await axios.get(targetUrl, { headers: { Authorization: authorizationHeader } }); console.log('Successfully made authenticated request:', result.data); return result.data; } else { throw error; // Re-throw other errors } } } makeDigestAuthenticatedRequest().catch(console.error);
Debug
Known issues
gotchaWhen `qop` (Quality of Protection) is set to `auth-int` in the `WWW-Authenticate` header, the `entityBody` parameter is no longer optional for `generateDigestAuth`. Failing to provide it will result in an incorrect digest string.
fix
Ensure `entityBody` is passed to `generateDigestAuth` when `qop='auth-int'`. The value should be the actual request body content.
affects: >=0.1.0
gotchaThe `nc` (nonce count) parameter, if provided, is expected to be a hexadecimal string. When `generateDigestAuth` is called with an `nc`, the returned header's `nc` value will be incremented by 1 (in hexadecimal) to reflect the next expected nonce count for subsequent requests.
fix
Be aware of the `nc` incrementing behavior if you manage nonce counts manually. Use `findNonceCount` to extract the `nc` from a previous response if needed for sequential calls.
affects: >=0.1.0
gotchaThe library requires Node.js version 12.0.0 or higher. Running in older Node.js environments may lead to unexpected errors or crashes due to unsupported syntax or APIs.
fix
Upgrade your Node.js runtime environment to version 12.0.0 or newer. Consider using a Node Version Manager (NVM) for easy switching.
affects: <12.0.0 (runtime)
Errors
Common errors & fixes
Error: Missing entityBody for qop='auth-int'
Attempting to generate a Digest header for a `qop=auth-int` challenge without providing the `entityBody` parameter.
fix
Provide the `entityBody` (the actual request body content) as a string to the `generateDigestAuth` function when `qop` is `auth-int`.
TypeError: indigestion.generateDigestAuth is not a function
Incorrect import statement or attempting to call `indigestion` as a function or directly accessing properties on `indigestion` when a default export is not an object or named exports are expected differently.
fix
For modern ESM and TypeScript, use `import { generateDigestAuth } from 'indigestion';`. If using CommonJS, use `const { generateDigestAuth } = require('indigestion');`.
Upgrade
Version history
0.03latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
indigestion — npm install indigestion · libregistry