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

@node-ntlm/httpreq

v0.3.2

Published

NTLM httpreq node utility function

Downloads

349

Readme

@node-ntlm/httpreq

@node-ntlm/httpreq is a Node.js library to do HTTP NTLM authentication

It's heavily inspired from httpntlm written in typescript, promise based and with nodejs 18 support.

Install

You can install @node-ntlm/httpreq using the Node Package Manager (npm):

npm install @node-ntlm/httpreq

How to use

import { get } from '@node-ntlm/httpreq';

const res = await get({
    url: 'https://someurl.com',
    username: 'm$',
    password: 'stinks',
    workstation: 'choose.something',
    domain: '',
});

console.log(res.headers);
console.log(res.body);

It supports http and https.

pre-encrypt the password

import { get } from '@node-ntlm/httpreq';
import { createLMHashedPasswordV1, createNTHashedPasswordV1 } from '@node-ntlm/httpreq';

let lm = createLMHashedPasswordV1('Azx123456');
let nt = createNTHashedPasswordV1('Azx123456');

console.log(lm);
console.log(Array.prototype.slice.call(lm, 0));

lm = new Buffer([183, 180, 19, 95, 163, 5, 118, 130, 30, 146, 159, 252, 1, 57, 81, 39]);

console.log(lm);

console.log(nt);
console.log(Array.prototype.slice.call(nt, 0));

nt = new Buffer([150, 27, 7, 219, 220, 207, 134, 159, 42, 60, 153, 28, 131, 148, 14, 1]);

console.log(nt);

const res = await get({
    url: 'https://someurl.com',
    username: 'm$',
    lm_password: lm,
    nt_password: nt,
    workstation: 'choose.something',
    domain: '',
});

console.log(res.headers);
console.log(res.body);

/* you can save the array into your code and use it when you need it

<Buffer b7 b4 13 5f a3 05 76 82 1e 92 9f fc 01 39 51 27>// before convert to array
[ 183, 180, 19, 95, 163, 5, 118, 130, 30, 146, 159, 252, 1, 57, 81, 39 ]// convert to array
<Buffer b7 b4 13 5f a3 05 76 82 1e 92 9f fc 01 39 51 27>//convert back to buffer

<Buffer 96 1b 07 db dc cf 86 9f 2a 3c 99 1c 83 94 0e 01>
[ 150, 27, 7, 219, 220, 207, 134, 159, 42, 60, 153, 28, 131, 148, 14, 1 ]
<Buffer 96 1b 07 db dc cf 86 9f 2a 3c 99 1c 83 94 0e 01>
*/

Options

  • url: {String} URL to connect. (Required)
  • username: {String} Username. (Required)
  • password: {String} Password. (Required)
  • workstation: {String} Name of workstation or ''.
  • domain: {String} Name of domain or ''.

if you already got the encrypted password,you should use this two param to replace the 'password' param.

  • lm_password {Buffer} encrypted lm password.(Required)
  • nt_password {Buffer} encrypted nt password. (Required)

You can also pass along all other options of httpreq, including custom headers, cookies, body data, ... and use POST, PUT or DELETE instead of GET.

NTLMv2

When NTLMv2 extended security and target information can be negotiated with the server, this library assumes the server supports NTLMv2 and creates responses according to the NTLMv2 specification (the actually supported NTLM version cannot be negotiated). Otherwise, NTLMv1 or NTLMv1 with NTLMv2 extended security will be used.

Download binary files

import { writeFile } from 'node:fs/promises';

import { get } from '@node-ntlm/httpreq';

try {
    const response = await get({
        url: 'https://someurl.com/file.xls',
        username: 'm$',
        password: 'stinks',
        workstation: 'choose.something',
        domain: '',
        binary: true,
    });

    await writeFile('file.xls', response.body, { encoding: 'utf8' });

    console.log('file.xls saved!');
} catch (error) {
    console.log('An error occurred', error);
}