# @ewsjs/ntlm-client

> A node.js NTLM client with support for NTLM and NTLMv2 authentication, forked from clncln1/node-ntlm-client

Latest version **3.0.1** (published 2024-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ewsjs/ntlm-client
pnpm add @ewsjs/ntlm-client
yarn add @ewsjs/ntlm-client
bun add @ewsjs/ntlm-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2024-02-25 |
| First published | 2019-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 2 |
| Unpacked size | 26 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nico Haller |
| Maintainers | gautamsi |
| Keywords | ntlm, ntlmv2, client, authentication |

## Links

- npm: https://www.npmjs.com/package/@ewsjs/ntlm-client
- Repository: https://github.com/ewsjs/ntlm-client
- Homepage: https://github.com/ewsjs/ntlm-client#readme
- Issues: https://github.com/ewsjs/ntlm-client/issues
- npm.io page: https://npm.io/package/@ewsjs/ntlm-client

## Dependencies (2)

- [des.js](https://npm.io/package/des.js.md) ^1.1.0
- [js-md4](https://npm.io/package/js-md4.md) ^0.3.2

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2024-02-25
- 3.0.0 — 2024-02-25
- 2.0.0 — 2023-09-10
- 1.0.0 — 2019-07-18

## README

# @ewsjs/ntlm-client (original: ntlm-client)

A node.js NTLM client with support for NTLM and NTLMv2 authentication, forked from [clncln1/node-ntlm-client](https://github.com/clncln1/node-ntlm-client), see [reason for forking](https://github.com/gautamsi/ews-javascript-api/issues/309) and the PR https://github.com/clncln1/node-ntlm-client/pull/4 which is stuck at the time of publishing

```
npm install @ewsjs/ntlm-client
```

## UPDATE 3.0
Fixes node 18+ issues with removed md4 and des ciphers, solution ref https://github.com/SamDecrock/node-http-ntlm/pull/107

## API

#### request(options) (OPTIONAL)
> `request` is removed from dependency. to use this you have to add `request` in dependency and import like this `const ntlmrequest = require('@ewsjs/ntlm-client/lib/ntlmrequest')`. You also need to add `extend` in dependency.

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

---
_Source: https://npm.io/package/@ewsjs/ntlm-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
