@ewsjs/ntlm-client v3.0.1
@ewsjs/ntlm-client (original: ntlm-client)
A node.js NTLM client with support for NTLM and NTLMv2 authentication, forked from clncln1/node-ntlm-client, see reason for forking and the PR https://github.com/clncln1/node-ntlm-client/pull/4 which is stuck at the time of publishing
npm install @ewsjs/ntlm-clientUPDATE 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)
requestis removed from dependency. to use this you have to addrequestin dependency and import like thisconst ntlmrequest = require('@ewsjs/ntlm-client/lib/ntlmrequest'). You also need to addextendin 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
optionsan object holding below options for the authentication process:urithe target URLmethodthe HTTP verbusernamepasswordrequestthis is optional. An object that holds options that should be passed to the request instance
- Returns
Promisewhen resolved, therequestinstance, the result and the response body will be passed
createType1Message(workstation, target)
Creates a type 1 NTLM message to initialize the NTLM handshake
- Arguments
workstationOptional. Ifundefined,os.hostname()will be usedtargetOptional. This is the domain/host we are trying to authenticate against.
- Returns
stringComplete NTLM string that should be sent to the server in theAuthenticationheader
decodeType2Message(str)
Decodes a type 2 message received from the server including the NTLM challenge
- Arguments
strEither the base64 encoded type 2 message, or the completeWWW-Authenticateheader, or an object containg the response headers (http.IncomingMessage)
- Returns
type2MessageAn 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
type2MessageThe decoded type 2 message objectusernamepasswordworkstationOptional. If falsy,os.hostname()will be usedtargetOptional. 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
stringComplete NTLM string that should be sent to the server in theAuthenticationheader