request-ntlm-promise
Version:
Make easy requests with NTLM authentication
70 lines (56 loc) • 1.96 kB
Markdown
[](http://standardjs.com)

Ntlm authentication _promise_ wrapper for the Request module. It authenticates each request via NTLM protocol.
The core of this reposotory comes from [request-ntlm](https://github.com/colynb/request-ntlm) which was improved by [request-ntlm-continued](https://github.com/FrankyBoy/request-ntlm). Here you can find complete refactor of both with ability to use promises.
```
$ npm install request-ntlm-promise
```
```
const ntlm = require('request-ntlm-promise');
// Typescript
import * as Request from 'request-ntlm-promise';
```
- `username`: username;
- `password`: password;
- `ntlm_domain`: domain either http or https;
- `url`: complete path to the resource;
- `workstation`: workstation;
- other options, which should be passed to Request module e.g. default headers.
This can be `string` or `object`
Optional. If provided then you will get a stream instead of promise. Useful if working with files.
```javascript
const ntlm = require('request-ntlm-promise');
const URL = 'http://yourdomain.com'
const options = {
username: 'username',
password: 'password',
ntlm_domain: URL,
url: `${URL}/path/to/resource`
};
const json = {
// whatever object you want to submit
};
ntlm.post(options, json).then(console.log)
// or use async/await
const data = await ntlm.post(options, json)
console.log(data)
// or stream
ntlm.post(options, json, (response) => {
reply(response) // Hapi js handler
})
```