npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@elastic.io/ntlm-client

v1.0.0

Published

A node.js NTLM client with support for NTLM and NTLMv2 authentication. Continuation of ntlm-client and node-ntlm-client.

Downloads

407

Readme

ntlm-client

A node.js NTLM client with support for NTLM and NTLMv2 authentication

npm install ntlm-client

Example Usage

const ntlmRequest = require('@elasticio/ntlm-client').request;

(async function makeExampleRequest() {
  const { response } = await ntlmRequest({
    username: 'MYDOMAIN\SomeUser',
    password: 'P@$$word1!',
    uri: 'https://api.someservice.com',
    method: 'POST',
    request: {
      json: true,   // Example of parameter passed to request.js
      body: {
        foo: 'bar'
      },
      headers: {
        Date: 'Today'
      }
    }
  });
  console.log(`Received status code: ${response.statusCode} Body: ${response.body}`);
})()

API

request(options)

A convenience function that tries to authenticate against a given URL using the request module. If NTLM is not supported, it will fallback to Basic Auth.

  • Arguments
    • options an object holding below options for the authentication process:
      • uri the target URL
      • method the HTTP verb
      • username
      • password
      • request this is optional. An object that holds options that should be passed to the request instance
  • Returns
    • Promise when resolved, the request instance, the result and the response body will be passed

createType1Message([workstation, target])

Creates a type 1 NTLM message to initialize the NTLM handshake

  • Arguments
    • workstation Optional. If undefined, os.hostname() will be used
    • target Optional. This is the domain/host we are trying to authenticate against.
  • Returns
    • string Complete NTLM string that should be sent to the server in the Authentication header

decodeType2Message(str)

Decodes a type 2 message received from the server including the NTLM challenge

  • Arguments
    • str Either the base64 encoded type 2 message, or the complete WWW-Authenticate header, or an object containg the response headers (http.IncomingMessage)
  • Returns
    • type2Message An object containing the following information about the received type 2 message: flags, encoding, version, challenge, targetName, targetInfo.

createType3Message(type2Message, username, password[, workstation, target])

Creates a type 3 message based on the type 2 message received from the server.

  • Arguments
    • type2Message The decoded type 2 message object
    • username
    • password
    • workstation Optional. If falsy, os.hostname() will be used
    • target Optional. If falsy, the target name from the type 2 message will be used. This is the domain/host we are trying to authenticate against.
  • Returns
    • string Complete NTLM string that should be sent to the server in the Authentication header