{"id":16728,"library":"indigestion","title":"Digest Authentication Header Generator","description":"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.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/aaron-goff/indigestion","tags":["javascript","digest","authentication","auth","header","typescript"],"install":[{"cmd":"npm install indigestion","lang":"bash","label":"npm"},{"cmd":"yarn add indigestion","lang":"bash","label":"yarn"},{"cmd":"pnpm add indigestion","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import indigestion = require('indigestion'); const digest = indigestion.generateDigestAuth(...);","symbol":"generateDigestAuth","correct":"import { generateDigestAuth } from 'indigestion';"},{"note":"Utility function for parsing the nonce count from an existing Digest header. Follows standard named import patterns.","wrong":"const findNonceCount = require('indigestion').findNonceCount;","symbol":"findNonceCount","correct":"import { findNonceCount } from 'indigestion';"}],"quickstart":{"code":"import axios from \"axios\";\nimport { generateDigestAuth } from 'indigestion';\n\nasync function makeDigestAuthenticatedRequest() {\n  const username = process.env.DIGEST_USERNAME ?? 'testuser';\n  const password = process.env.DIGEST_PASSWORD ?? 'testpass';\n  const targetUrl = 'http://www.example.com/protected/resource'; // Replace with your target URL\n  const method = 'GET';\n\n  try {\n    // First attempt: Expect a 401 Unauthorized response\n    await axios.get(targetUrl);\n  } catch (error: any) {\n    if (error.response && error.response.status === 401) {\n      const authenticateHeader = error.response.headers['www-authenticate'];\n      if (!authenticateHeader) {\n        throw new Error('WWW-Authenticate header not found in 401 response.');\n      }\n\n      // Generate the Digest Authorization header\n      const authorizationHeader = generateDigestAuth({\n        authenticateHeader,\n        username,\n        password,\n        uri: new URL(targetUrl).pathname,\n        method\n      });\n\n      // Retry the request with the generated Authorization header\n      const result = await axios.get(targetUrl, {\n        headers: {\n          Authorization: authorizationHeader\n        }\n      });\n      console.log('Successfully made authenticated request:', result.data);\n      return result.data;\n    } else {\n      throw error; // Re-throw other errors\n    }\n  }\n}\n\nmakeDigestAuthenticatedRequest().catch(console.error);\n","lang":"typescript","description":"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."},"warnings":[{"fix":"Ensure `entityBody` is passed to `generateDigestAuth` when `qop='auth-int'`. The value should be the actual request body content.","message":"When `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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade your Node.js runtime environment to version 12.0.0 or newer. Consider using a Node Version Manager (NVM) for easy switching.","message":"The 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.","severity":"gotcha","affected_versions":"<12.0.0 (runtime)"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Provide the `entityBody` (the actual request body content) as a string to the `generateDigestAuth` function when `qop` is `auth-int`.","cause":"Attempting to generate a Digest header for a `qop=auth-int` challenge without providing the `entityBody` parameter.","error":"Error: Missing entityBody for qop='auth-int'"},{"fix":"For modern ESM and TypeScript, use `import { generateDigestAuth } from 'indigestion';`. If using CommonJS, use `const { generateDigestAuth } = require('indigestion');`.","cause":"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.","error":"TypeError: indigestion.generateDigestAuth is not a function"}],"ecosystem":"npm"}