# @node-ntlm/core

> NTLM node utility function

Latest version **0.3.2** (published 2023-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @node-ntlm/core
pnpm add @node-ntlm/core
yarn add @node-ntlm/core
bun add @node-ntlm/core
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2023-02-08 |
| First published | 2023-02-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.19.0 |
| Dependencies | 3 |
| Unpacked size | 53.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | skrtheboss |
| Keywords | ntlm, md4, des, node18, node16, node, iis, authentication, windows authentication, windows, auth |

## Links

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

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.5.0
- [des.js](https://npm.io/package/des.js.md) ^1.0.1
- [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

- 0.3.2 (latest) — 2023-02-08
- 0.3.1 — 2023-02-08
- 0.3.0 — 2023-02-07
- 0.2.3 — 2023-02-07
- 0.2.2 — 2023-02-07
- 0.2.0 — 2023-02-06
- 0.1.5 — 2023-02-02

## README

# @node-ntlm/core

<p align="center">
  <a href="https://nodejs.org/">
    <img alt="NodeJs Support" src="https://img.shields.io/node/v/@node-ntlm/core?style=flat-square&logo=Node.js">
  </a>
  <a href="https://www.npmjs.com/package/@node-ntlm/core">
    <img alt="weekly downloads from npm" src="https://img.shields.io/npm/dw/@node-ntlm/core.svg?style=flat-square">
  </a>
  <a href="https://renovatebot.com/">
    <img alt="Renovate Bot" src="https://img.shields.io/badge/renovate-enabled-brightgreen.svg?style=flat-square">
  </a>
  <a href="https://snyk.io/advisor/npm-package/@node-ntlm/core">
    <img alt="SNYK Report" src="https://img.shields.io/snyk/vulnerabilities/npm/@node-ntlm/core?style=flat-square">
  </a>
  <a href="https://www.npmjs.org/package/@node-ntlm/core">
    <img alt="npm version" src="http://img.shields.io/npm/v/@node-ntlm/core.svg?style=flat-square&logo=npm">
  </a>
  <br/>
  <a href="https://bundlephobia.com/result?p=@node-ntlm/core">
    <img alt="Minified size" src="https://img.shields.io/bundlephobia/min/@node-ntlm/core?style=flat-square">
  </a>
  <a href="https://bundlephobia.com/result?p=@node-ntlm/coree">
    <img alt="Minified-Zipped size" src="https://img.shields.io/bundlephobia/minzip/@node-ntlm/core?style=flat-square">
  </a>
  <a href="https://github.com/semantic-release/semantic-release">
    <img alt="Semantic Release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-blue.svg?style=flat-square">
  </a>
  <a href="https://github.com/prettier/prettier">
    <img alt="code style: prettier" src="https://img.shields.io/badge/code%20style-prettier-blue?style=flat-square&logo=Prettier">
  </a>
  <a href="https://github.com/skrtheboss/node-ntlm/blob/master/LICENSE">
    <img alt="Mit License" src="https://img.shields.io/npm/l/@node-ntlm/core?color=blue&style=flat-square">
  </a>
</p>

**@node-ntlm/core** is a Node.js NTLM utility package

It's heavily inspired from [httpntlm](https://github.com/SamDecrock/node-http-ntlm) written in typescript and with nodejs 18 support.

## Install

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

    npm install @node-ntlm/core

## How to use

```typescript
import {
    createType1Message,
    createType3Message,
    extractNtlmMessageFromAuthenticateHeader,
    parseType2Message,
} from '@node-ntlm/core';
import { fetch } from 'undici';

const negotiateMessage = createType1Message({ domain: 'test.host', workstation: 'pc1' });

const negotiateResponse = await fetch('http://test-service.url/api', {
    headers: { authorization: negotiateMessage },
    keepalive: true,
});

const type2Message = extractNtlmMessageFromAuthenticateHeader(negotiateResponse.headers.get('www-authenticate'));

if (!type2Message) {
    throw new Error('Could not find type 2 message on response headers!');
}

const authMessage = createType3Message(parseType2Message(type2Message), {
    domain: 'test.host',
    workstation: 'pc1',
    username: 'test',
    password: 'test',
});

const result = await fetch('http://test-service.url/api', {
    headers: { Authorization: authMessage },
    keepalive: false,
});

console.log(await result.json());
```

# @node-ntlm/core/testing

## Usage:

```typescript
import { generateNegotiateResponse } from '@node-ntlm/core/testing';

const negotiateRespnse = generateNegotiateResponse(...getAuthorization header somewhere)
```

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