The `http-auth-utils` library provides synchronous, pure functions designed for parsing and building HTTP `WWW-Authenticate` and `Authorization` headers according to relevant HTTP RFCs. As of its current stable version, 7.0.1, it requires Node.js >= 24.14.0, signifying its alignment with modern JavaScript environments and practices, likely including ESM-first distribution. While a specific release cadence isn't mentioned, major version bumps suggest regular and significant updates. The library is framework-agnostic, suitable for both server and client-side JavaScript/TypeScript applications. Its key differentiators include a pure functional design without side effects, synchronous operations optimized for small header sizes, and explicit extensibility, allowing developers to integrate custom authentication schemes beyond the built-in support for Basic, Digest, and Bearer. This offers a lightweight, focused solution for HTTP header manipulation without the overhead of full-fledged authentication systems.
npm install http-auth-utilsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing incoming Authorization headers (e.g., Bearer tokens), building WWW-Authenticate challenge headers for server responses, and constructing Authorization headers for client requests using Basic authentication, showcasing the library's core functionalities.
Upgrade your Node.js runtime to version 24.14.0 or higher, or downgrade `http-auth-utils` to a compatible major version (e.g., `npm install http-auth-utils@^6`).
Refer to the official `http-auth-utils` v7 release notes and migration guide on GitHub for detailed breaking changes and recommended adjustments to your codebase.
Ensure your project is configured to use ES Modules (e.g., by setting `"type": "module"` in `package.json` or by using a bundler like Webpack/Rollup). Always use `import` statements for `http-auth-utils`.
Provide an explicit array of mechanisms: `parseAuthorizationHeader(header, [MY_CUSTOM_MECHANISM, BEARER])`.
If you encounter issues with header parsing due to casing differences, consider setting `options.strict: false` as needed: `parseAuthorizationHeader(header, undefined, { strict: false })`. However, be aware this might lead to less precise matching.Change `const { parseAuthorizationHeader } = require('http-auth-utils');` to `import { parseAuthorizationHeader } from 'http-auth-utils';`. Ensure your `package.json` has `"type": "module"` if this is a top-level script, or use a bundler.Verify that your import statement is correct (`import { parseAuthorizationHeader } from 'http-auth-utils';`) and that your build/runtime environment correctly handles ES Modules. If using CommonJS, you might need to use dynamic `import()` or downgrade the library.Ensure you define your custom mechanism (e.g., `const MY_CUSTOM_MECHANISM = { type: 'CustomAuth', parse: () => {}, build: () => {} };`) and pass it in the `authMechanisms` array: `parseAuthorizationHeader(header, [BASIC, MY_CUSTOM_MECHANISM])`.Check the exact format of the header string you are passing. Ensure it adheres to the HTTP RFC specifications for `WWW-Authenticate` or `Authorization` headers. You may also try setting `{ strict: false }` in the options object if minor deviations are expected.No dependency data recorded yet.