The `basic-auth-parser` package provides a minimalist utility for parsing the `Authorization` HTTP header specifically for Basic Authentication schemes. It extracts the authentication scheme (e.g., 'Basic'), username, and password from a base64-encoded header string. The current stable version is 0.0.2-1, which was last published over four years ago, indicating that the package is no longer actively maintained. Due to its age and lack of updates, it does not support modern JavaScript module systems like ESM out-of-the-box, relying solely on CommonJS. Key differentiators from more actively maintained alternatives like `basic-auth` (from `jshttp`) or `http-auth-utils` include its extremely small footprint and singular focus, but this comes at the cost of modern features, security updates, and broader ecosystem support.
npm install basic-auth-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse a Basic Auth `Authorization` header string using `basic-auth-parser`, showing both successful parsing and handling of invalid inputs.
Migrate to a maintained library like `basic-auth` (`npm install basic-auth`) or `http-auth-utils` (`npm install http-auth-utils`).
For ESM projects, consider using a dynamic `import()` statement or a CommonJS-compatible module loader, or switch to an ESM-native alternative. Example for ESM: `const basicAuthParser = await import('basic-auth-parser').then(m => m.default || m);`Always check for `null` return values and implement robust error handling or use a more comprehensive HTTP auth parsing library if supporting multiple schemes is required.
Ensure the module is correctly imported using `const basicAuthParser = require('basic-auth-parser');` for CommonJS. If in ESM, consider `const basicAuthParser = require('basic-auth-parser');` or a dynamic import with proper default export handling: `const { default: basicAuthParser } = await import('basic-auth-parser');`Revert to CommonJS `require()` syntax: `const basicAuthParser = require('basic-auth-parser');`.No dependency data recorded yet.