digest-client
Version:
Allows to make requests to servers with Digest Authentication
65 lines (50 loc) • 2.27 kB
Markdown
# Node.js Digest Client
### It seems, that this package does not make sense anymore, because [request.js](https://github.com/request/request#http-authentication) has implemented Digest Authentication and has more comfortable API
This module allows making requests to servers through Digest Authentication [(see wikipedia for details)](https://www.wikiwand.com/en/Digest_access_authentication)
## Usage
### DigestClient.get
```
var DigestClient = require('digest-client');
var digestClient = new DigestClient({username: 'foo', password: 'bar', https: true});
digestClient.get('https://hostname.com/path', function(err, result) {
if (err) {
return console.log(err);
}
console.log(result);
})
```
### DigestClient.request
```
var DigestClient = require('digest-client');
var digestClient = new DigestClient({username: 'foo', password: 'bar', https: true});
digestClient.request({
host: 'hostname.com',
path: '/path.json',
port: 80,
method: 'GET',
headers: { "User-Agent": "Shmuser-Shmagent" }
}, function (err, result) {
if (err) {
return console.log(err);
}
console.log(result);
});
```
### How it works
The digest client will make one request to the server, then parse response (which contains authentication data)
and then make authenticated request.
## Contributions
Contributions are very welcome!
# License
This is fork of lib, originally made by Simon Ljungberg. Author did not accept PRs and was kinda inactive, so development goes here.
Copyright (c) 2015, Ivan Skorokhodov <iskorokhodov@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.