Socket
Socket
Sign inDemoInstall

httpntlm

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpntlm - npm Package Compare versions

Comparing version 1.8.9 to 1.8.10

3

httpntlm.js

@@ -60,2 +60,3 @@ /**

type1options = _.extend({}, _.omit(httpreqOptions, 'headers', 'body'), type1options);
if(httpreqOptions.headers) type1options.headers = _.extend(type1options.headers, _.omit(httpreqOptions.headers, 'Connection', 'Authorization'));

@@ -95,4 +96,4 @@ // send type1 message to server:

// pass along other options:
type3options.headers = _.extend(type3options.headers, httpreqOptions.headers);
type3options = _.extend(type3options, _.omit(httpreqOptions, 'headers'));
if(httpreqOptions.headers) type3options.headers = _.extend(type3options.headers, _.omit(httpreqOptions.headers, 'Connection', 'Authorization'));

@@ -99,0 +100,0 @@ // send type3 message to server:

{
"name": "httpntlm",
"description": "httpntlm is a Node.js library to do HTTP NTLM authentication",
"version": "1.8.9",
"version": "1.8.10",
"dependencies": {

@@ -6,0 +6,0 @@ "des.js": "^1.0.1",

@@ -30,12 +30,12 @@ # httpntlm

httpntlm.get({
url: "https://someurl.com",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: ''
url: "https://someurl.com",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: ''
}, function (err, res){
if(err) return console.log(err);
if(err) return console.log(err);
console.log(res.headers);
console.log(res.body);
console.log(res.headers);
console.log(res.body);
});

@@ -48,3 +48,2 @@ ```

```js
var httpntlm = require('httpntlm');

@@ -66,13 +65,13 @@ var ntlm = httpntlm.ntlm;

httpntlm.get({
url: "https://someurl.com",
username: 'm$',
lm_password: lm,
nt_password: nt,
workstation: 'choose.something',
domain: ''
url: "https://someurl.com",
username: 'm$',
lm_password: lm,
nt_password: nt,
workstation: 'choose.something',
domain: ''
}, function (err, res){
if(err) return console.log(err);
if(err) return console.log(err);
console.log(res.headers);
console.log(res.body);
console.log(res.headers);
console.log(res.body);
});

@@ -102,2 +101,3 @@

- `agent:` _{Agent}_ In case you want to reuse the keepaliveAgent over different calls (optional)
- `headers:` _{Object}_ Add in custom headers. The following headers are used by NTLM and cannot be passed: `Connection`, `Authorization` (optional)

@@ -130,45 +130,45 @@ if you already got the encrypted password,you should use this two param to replace the 'password' param.

var options = {
url: "https://someurl.com",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: ''
url: "https://someurl.com",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: ''
};
async.waterfall([
function (callback){
var type1msg = ntlm.createType1Message(options);
function (callback){
var type1msg = ntlm.createType1Message(options);
httpreq.get(options.url, {
headers:{
'Connection' : 'keep-alive',
'Authorization': type1msg
},
agent: keepaliveAgent
}, callback);
},
httpreq.get(options.url, {
headers:{
'Connection' : 'keep-alive',
'Authorization': type1msg
},
agent: keepaliveAgent
}, callback);
},
function (res, callback){
if(!res.headers['www-authenticate'])
return callback(new Error('www-authenticate not found on response of second request'));
function (res, callback){
if(!res.headers['www-authenticate'])
return callback(new Error('www-authenticate not found on response of second request'));
var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
var type3msg = ntlm.createType3Message(type2msg, options);
var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
var type3msg = ntlm.createType3Message(type2msg, options);
setImmediate(function() {
httpreq.get(options.url, {
headers:{
'Connection' : 'Close',
'Authorization': type3msg
},
allowRedirects: false,
agent: keepaliveAgent
}, callback);
});
}
setImmediate(function() {
httpreq.get(options.url, {
headers:{
'Connection' : 'Close',
'Authorization': type3msg
},
allowRedirects: false,
agent: keepaliveAgent
}, callback);
});
}
], function (err, res) {
if(err) return console.log(err);
if(err) return console.log(err);
console.log(res.headers);
console.log(res.body);
console.log(res.headers);
console.log(res.body);
});

@@ -179,19 +179,39 @@ ```

```javascript
```js
httpntlm.get({
url: "https://someurl.com/file.xls",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: '',
binary: true
url: "https://someurl.com/file.xls",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: '',
binary: true
}, function (err, response) {
if(err) return console.log(err);
fs.writeFile("file.xls", response.body, function (err) {
if(err) return console.log("error writing file");
console.log("file.xls saved!");
});
if(err) return console.log(err);
fs.writeFile("file.xls", response.body, function (err) {
if(err) return console.log("error writing file");
console.log("file.xls saved!");
});
});
```
## Pass in custom headers
```js
httpntlm.get({
url: "http://localhost:3000",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: 'somedomain',
headers: {
'User-Agent': 'my-useragent'
}
}, function (err, res){
if(err) return console.log(err);
console.log(res.headers);
console.log(res.body);
});
````
## More information

@@ -198,0 +218,0 @@

@@ -19,3 +19,6 @@ var express = require('express');

app.all('*', function(request, response) {
console.log('> incoming NTLM request', request.ntlm);
console.log('> incoming NTLM request');
console.log('> headers:', request.headers);
console.log('> ntlm data:', request.ntlm);
response.end(JSON.stringify(request.ntlm)); // {"DomainName":"MYDOMAIN","UserName":"MYUSER","Workstation":"MYWORKSTATION"}

@@ -22,0 +25,0 @@ });

@@ -47,3 +47,25 @@ var httpntlm = require('../httpntlm');

function test_customHeaders() {
httpntlm.get({
url: "http://localhost:3000",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: 'somedomain',
headers: {
'User-Agent': 'my-useragent',
'Authorization': 'will-be-omitted-by-the-module'
}
}, function (err, res){
if(err) return console.log(err);
console.log(res.headers);
console.log(res.body);
});
}
test_simpleAuthorization();
test_reuseKeepaliveAgent();
test_reuseKeepaliveAgent();
test_customHeaders();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc