{"id":49751,"library":"with-digest-fetch","title":"with-digest-fetch","description":"A lightweight library for HTTP Digest Authentication, compatible with both the Fetch API and node-fetch. Version 0.7.0 (stable, with regular releases) provides both ESM and CJS bundles, as well as TypeScript declarations. Forked from digest-fetch to add multi-format module support and improved TypeScript integration. Ideal for Node.js environments that need to authenticate against HTTP Digest servers with minimal overhead, offering a simple client that wraps fetch calls.","status":"active","version":"0.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/zoubingwu/with-digest-fetch","tags":["javascript","digest","auth","fetch","node-fetch","http","basic","authentication","typescript"],"install":[{"cmd":"npm install with-digest-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add with-digest-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add with-digest-fetch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for Node.js environments that lack native fetch (v2.x). Optional when using native fetch in Node 18+ or browsers.","package":"node-fetch","optional":true}],"imports":[{"note":"Default import only; the module exports a single class. CommonJS users should use the default import syntax in TypeScript or 'const DigestClient = require('with-digest-fetch').default' with esModuleInterop.","wrong":"const DigestClient = require('with-digest-fetch')","symbol":"DigestClient","correct":"import DigestClient from 'with-digest-fetch'"},{"note":"TypeScript users can import the options interface for better type safety.","symbol":"DigestClientOptions","correct":"import type { DigestClientOptions } from 'with-digest-fetch'"},{"note":"TypeScript type for the internal auth context; rarely needed but available.","symbol":"DigestAuthContext","correct":"import type { DigestAuthContext } from 'with-digest-fetch'"}],"quickstart":{"code":"import DigestClient from 'with-digest-fetch';\nimport fetch from 'node-fetch';\n\nasync function main() {\n  const client = new DigestClient('user', 'password', { algorithm: 'MD5' });\n  const url = 'https://httpbin.org/digest-auth/auth/user/password/MD5';\n  const response = await client.fetch(url, { method: 'GET' });\n  console.log(await response.text());\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Creates a DigestClient with credentials and fetches a protected URL, printing the response."},"warnings":[{"fix":"Ensure node-fetch is installed and imported if using Node <18.","message":"The client expects the fetch function to be compatible with the standard Response object. Using older versions of node-fetch (<=2.x) may require explicit import.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use import syntax or set esModuleInterop: true in tsconfig.json and use require('with-digest-fetch').default.","message":"The package switched from digest-fetch's CommonJS-only to dual ESM/CJS. Consumers using require() without esModuleInterop may need to access .default.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Do not include 'Authorization' header; the client manages it.","message":"The 'auth' option in fetch is not used; authentication is handled automatically by the client. Passing credentials in options may cause confusion.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use a different library for non-Digest/Basic auth.","message":"The client only supports Digest and Basic authentication schemes. NTLM or other schemes are not supported.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Explicitly set qop: 'auth' or omit to use default.","message":"The 'qop' option has a default value of 'auth' in some implementations; ensure server compatibility.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.7.0':23 'add':45 'api':17 'auth':80 'authent':11,62,87 'basic':86 'bundl':33 'call':77 'cjs':32 'client':73 'compat':12 'declar':38 'digest':3,10,42,65,79 'digest-fetch':41 'environ':58 'esm':30 'fetch':4,16,21,43,76,81,84 'fork':39 'format':48 'http':9,64,85 'ideal':55 'improv':52 'integr':54 'javascript':78 'librari':7 'lightweight':6 'minim':68 'modul':49 'multi':47 'multi-format':46 'need':60 'node':20,83 'node-fetch':19,82 'node.js':57 'offer':70 'overhead':69 'provid':28 'regular':26 'releas':27 'server':66 'simpl':72 'stabl':24 'support':50 'typescript':37,53,88 'version':22 'well':35 'with-digest-fetch':1 'wrap':75","created_at":"2026-06-07T17:03:25.486865+00:00","updated_at":"2026-06-07T17:03:25.486865+00:00","problems":[{"fix":"Install node-fetch: npm install node-fetch and import it: import fetch from 'node-fetch';","cause":"Node.js version <18 or missing node-fetch import.","error":"TypeError: fetch is not a function"},{"fix":"Use import DigestClient from 'with-digest-fetch' or const DigestClient = require('with-digest-fetch').default;","cause":"CommonJS require() without .default when esModuleInterop is false.","error":"DigestClient is not a constructor"},{"fix":"Run npm install with-digest-fetch and ensure tsconfig.json has 'moduleResolution': 'node' or 'node16'.","cause":"Missing package installation or TypeScript unable to resolve types.","error":"Cannot find module 'with-digest-fetch' or its corresponding type declarations."},{"fix":"Verify credentials and check if server requires Digest or Basic auth. Ensure algorithm matches (e.g., MD5, SHA-256).","cause":"Incorrect username, password, or server configuration (e.g., realm, nonce).","error":"Request failed with status 401 Unauthorized"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/zoubingwu/with-digest-fetch","github":"https://github.com/zoubingwu/with-digest-fetch","docs":null,"changelog":null,"pypi":null,"npm":"with-digest-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}