{"name":"httpntlm","description":"httpntlm is a Node.js library to do HTTP NTLM authentication","version":"1.4.1","dependencies":{"httpreq":"~0.4.2","async":"~0.2.9","agentkeepalive":"~0.1.5"},"author":{"name":"Sam Decrock","url":"https://github.com/SamDecrock/"},"bugs":{"url":"https://github.com/SamDecrock/node-http-ntlm/issues"},"engines":{"node":">= 0.8.0"},"repository":{"type":"git","url":"git://github.com/SamDecrock/node-http-ntlm.git"},"main":"./httpntlm","licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"scripts":{"jshint":"jshint *.js"},"gitHead":"a1d46038abc3375fb4a73284e938c608ef553341","homepage":"https://github.com/SamDecrock/node-http-ntlm","_id":"httpntlm@1.4.1","_shasum":"63d362fffe55a584f45632697c15d8d0fcb5a985","_from":".","_npmVersion":"1.4.12","_npmUser":{"name":"samdecrock","email":"sam.decrock@gmail.com"},"maintainers":[{"name":"samdecrock","email":"sam.decrock@gmail.com"}],"dist":{"shasum":"63d362fffe55a584f45632697c15d8d0fcb5a985","tarball":"http://registry-npm.ywwl.com/httpntlm/download/httpntlm-1.4.1.tgz","integrity":"sha512-q15XUULKWMQRLYDMPfaBZXuTvrIgpT7y4GOEDhvYJyZ1YYXld4xISodW08Ior7lNEP0ToRzcryRBY3vjDEYypQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAIrR/Jv4pzjZ63/JBxDoX4SF9CPLL//UQzPYJEzm+sBAiEAhb045WuY1GKouHJ80ajg8K0tHiQZbzB3FnHySovY5I4="}],"size":6085,"noattachment":false,"key":"/httpntlm/-/httpntlm-1.4.1.tgz"},"directories":{},"readme":"# httpntlm\n\n__httpntlm__ is a Node.js library to do HTTP NTLM authentication\n\nIt's a port from the Python libary [python-ntml](https://code.google.com/p/python-ntlm/) with added NTLMv2 support.\n\n## Snyk security scan\n\n[![Known Vulnerabilities](https://snyk.io/test/github/SamDecrock/node-http-ntlm/badge.svg)](https://snyk.io/test/github/SamDecrock/node-http-ntlm)\n\n## Donate\n\nIf you've benefited from this module in any way, please consider donating!\n\n__Donations:__\n\n| Name       | amount   | when      |\n|------------|----------|-----------|\n| Tina Lacey | $ 20     | June 2018 |\n\nLast update: March 2023\n\n\n[![](https://neat.be/paypal-donate-button.png)](https://www.paypal.com/donate/?hosted_button_id=2CKNJLZJBW8ZC)\n\nThank you for your support!\n\n\n## Install\n\nYou can install __httpntlm__ using the Node Package Manager (npm):\n\n    npm install httpntlm\n\n## How to use\n\n```js\nvar httpntlm = require('httpntlm');\n\nhttpntlm.get({\n  url: \"https://someurl.com\",\n  username: 'm$',\n  password: 'stinks',\n  workstation: 'choose.something',\n  domain: ''\n}, function (err, res){\n  if(err) return console.log(err);\n\n  console.log(res.headers);\n  console.log(res.body);\n});\n```\n\n## Options\n\n- `url:`      _{String}_   URL to connect. (Required)\n- `username:` _{String}_   Username (optional, default: '')\n- `password:` _{String}_   Password (optional, default: '')\n- `workstation:` _{String}_ Name of workstation (optional, default: '')\n- `domain:`   _{String}_   Name of domain (optional, default: '')\n- `agent:`   _{Agent}_   In case you want to reuse the keepaliveAgent over different calls (optional)\n- `headers:`   _{Object}_   Add in custom headers. The following headers are used by NTLM and cannot be passed: `Connection`, `Authorization` (optional)\n\nif you already got the encrypted password,you should use this two param to replace the 'password' param.\n\n- `lm_password` _{Buffer}_ encrypted lm password.(Required)\n- `nt_password` _{Buffer}_ encrypted nt password. (Required)\n\nYou can also pass along all other options of [httpreq](https://github.com/SamDecrock/node-httpreq), including custom headers, cookies, body data, ... and use POST, PUT or DELETE instead of GET.\n\n## NTLMv2\n\nWhen NTLMv2 extended security and target information can be negotiated with the server, this library assumes\nthe server supports NTLMv2 and creates responses according to the NTLMv2 specification (the actually supported\nNTLM version cannot be negotiated).\nOtherwise, NTLMv1 or NTLMv1 with NTLMv2 extended security will be used.\n\n## Advanced\n\n### pre-encrypt the password\n```js\nvar httpntlm = require('httpntlm');\nvar ntlm = httpntlm.ntlm;\nvar lm = ntlm.create_LM_hashed_password('Azx123456');\nvar nt = ntlm.create_NT_hashed_password('Azx123456');\n\n\nhttpntlm.get({\n  url: \"https://someurl.com\",\n  username: 'm$',\n  lm_password: lm,\n  nt_password: nt,\n  workstation: 'choose.something',\n  domain: ''\n}, function (err, res){\n  if(err) return console.log(err);\n\n  console.log(res.headers);\n  console.log(res.body);\n});\n```\n\n### Use the NTLM-functions yourself\nIf you want to use the NTLM-functions yourself, you can access the ntlm-library like this (https example):\n\n```js\nvar ntlm = require('httpntlm').ntlm;\nvar async = require('async');\nvar httpreq = require('httpreq');\nvar HttpsAgent = require('agentkeepalive').HttpsAgent;\nvar keepaliveAgent = new HttpsAgent();\n\nvar options = {\n  url: \"https://someurl.com\",\n  username: 'm$',\n  password: 'stinks',\n  workstation: 'choose.something',\n  domain: ''\n};\n\nasync.waterfall([\n  function (callback){\n    var type1msg = ntlm.createType1Message(options);\n\n    httpreq.get(options.url, {\n      headers:{\n        'Connection' : 'keep-alive',\n        'Authorization': type1msg\n      },\n      agent: keepaliveAgent\n    }, callback);\n  },\n\n  function (res, callback){\n    if(!res.headers['www-authenticate'])\n      return callback(new Error('www-authenticate not found on response of second request'));\n\n    var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);\n    var type3msg = ntlm.createType3Message(type2msg, options);\n\n    setImmediate(function() {\n      httpreq.get(options.url, {\n        headers:{\n          'Connection' : 'Close',\n          'Authorization': type3msg\n        },\n        allowRedirects: false,\n        agent: keepaliveAgent\n      }, callback);\n    });\n  }\n], function (err, res) {\n  if(err) return console.log(err);\n\n  console.log(res.headers);\n  console.log(res.body);\n});\n```\n\n### Download binary files\n\n```js\nhttpntlm.get({\n  url: \"https://someurl.com/file.xls\",\n  username: 'm$',\n  password: 'stinks',\n  workstation: 'choose.something',\n  domain: '',\n  binary: true\n}, function (err, response) {\n  if(err) return console.log(err);\n  fs.writeFile(\"file.xls\", response.body, function (err) {\n    if(err) return console.log(\"error writing file\");\n    console.log(\"file.xls saved!\");\n  });\n});\n```\n\n### Pass in custom headers\n\n```js\nhttpntlm.get({\n  url: \"http://localhost:3000\",\n  username: 'm$',\n  password: 'stinks',\n  workstation: 'choose.something',\n  domain: 'somedomain',\n  headers: {\n    'User-Agent': 'my-useragent'\n  }\n}, function (err, res){\n  if(err) return console.log(err);\n\n  console.log(res.headers);\n  console.log(res.body);\n});\n```\n\n### More examples\n\nYou can find more examples on [Snyk](https://snyk.io/advisor/npm-package/httpntlm/example).\n\n## More information\n\n* [python-ntlm](https://code.google.com/p/python-ntlm/)\n* [NTLM Authentication Scheme for HTTP](https://web.archive.org/web/20200724074947/https://www.innovation.ch/personal/ronald/ntlm.html)\n* [LM hash on Wikipedia](http://en.wikipedia.org/wiki/LM_hash)\n\n## Tests\n\nRunning tests in an open source package is crucial for ensuring the quality and reliability of the codebase. When you submit code changes, it's essential to ensure that these changes don't break existing functionality or introduce new bugs.\n\nTests are written with Mocha.\n\nTo run tests, simply run:\n\n    npm test\n\nNote that the integration tests start up a simple express.js server with NTLM support. You might see some extra debugging info from that server when running integration tests.\n\n\n## License (MIT)\n\nCopyright (c) Sam Decrock <https://github.com/SamDecrock/>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","publish_time":1419413554065,"_cnpm_publish_time":1419413554065,"dist-tags":{"latest":"1.8.15"}}