Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

node-digest-auth

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-digest-auth

Digest Auth Package

latest
npmnpm
Version
1.0.4
Version published
Weekly downloads
6
500%
Maintainers
1
Weekly downloads
 
Created
Source

HTTP Digest Client

This module provides an implementation for communicating with HTTP servers that utilize digest authentication. It's been structured to allow seamless requests to endpoints that require this form of authentication.

Disclaimer

This client is designed based on experience with specific servers and might not cover all the intricacies of the HTTP digest authentication spec. It has been tested against a limited set of servers. While it satisfies the needs it was created for, users should employ caution and conduct tests against their specific use cases.

Installation

npm install node-digest-auth

Usage

import {createDigestClient } from 'node-digest-auth'

// 1 parameter: USERNAME
// 2 parameter: PASSWORD
// 3 parameter: SHOULD BE HTTPS
// 4 parameter: REQUEST SHOULD END OR NOT. IF NOT ENDED YOU CAN WRITE TO THE REQ.

const digest = createDigestClient('username', 'password', false, true);

digest.request({
  host: 'hostname.com',
  path: '/path.json',
  port: 80,
  method: 'GET',
  headers: { "User-Agent": "Raphael Fonseca" } // Custom headers can be added as needed
}, function(res) {
  res.on('data', function(data) {
    console.log(data.toString());
  });
  res.on('error', function(err) {
    console.error('Error occurred:', err);
  });
});

The client will initially make an unauthenticated request to the server. Once a challenge is received, the client computes the necessary authentication response and then repeats the request. If all goes well, the server should then authorize the request.

Writing to req

set the last parameter of createDigestClient to false, it will return the req and you can finish it later.

License

Please refer to the LICENSE file for detailed information on licensing.

FAQs

Package last updated on 20 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts