Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@node-ntlm/axios

skrtheboss277MIT0.3.2TypeScript support: included

NTLM axios node utility function

ntlm, md4, des, node18, node16, node, iis, http, https, axios, authentication, windows authentication, windows, auth

readme

@node-ntlm/axios

NodeJs Support weekly downloads from npm Renovate Bot SNYK Report npm version
Minified size Minified-Zipped size Semantic Release code style: prettier Mit License

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

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

Install

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

npm install @node-ntlm/axios

How to use

This example will create you a brand new axios instance you can utilise the same as any other axios instance

import { NtlmClient, NtlmCredentials } from '@node-ntlm/axios';

(async () => {
    const credentials: NtlmCredentials = {
        username: 'username',
        password: 'password',
        domain: 'domain',
    };

    const client = NtlmClient(credentials);

    try {
        const resp = await client({
            url: 'https://protected.site.example.com',
            method: 'get',
        });
        console.log(resp.data);
    } catch (err) {
        console.log(err);
        console.log('Failed');
    }
})();

With a custom Axios config

This shows how to pass in an axios config in the same way that you would when setting up any other axios instance.

Note: If doing this, be aware that http(s)Agents need to be attached to keep the connection alive. If there are none attached already, they will be added. If you are providing your own then you will need to set this up.

import { AxiosRequestConfig } from 'axios';
import { NtlmClient, NtlmCredentials } from '@node-ntlm/axios';

(async () => {
    const credentials: NtlmCredentials = {
        username: 'username',
        password: 'password',
        domain: 'domain',
    };

    const config: AxiosRequestConfig = {
        baseURL: 'https://protected.site.example.com',
        method: 'get',
    };

    const client = NtlmClient(credentials, config);

    try {
        const resp = await client.get('/api/123');
        console.log(resp);
    } catch (err) {
        console.log(err);
        console.log('Failed');
    }
})();

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.3.2 (2023-02-08)

Bug Fixes

  • core: fix createType1Message not working properly (#19) (0ee88db)

0.3.1 (2023-02-08)

Bug Fixes

  • support complex www-authenticate headers (#18) (07fdce2)

0.3.0 (2023-02-07)

Features