lib/passport-http/strategies/digest.js
function DigestStrategy(options, secret, validate) {
  if (typeof options == 'function') {
    validate = secret;
    secret = options;
    options = {};
  }
  if (!secret) throw new Error('HTTP Digest authentication strategy requires a secret function');
  
  passport.Strategy.call(this);
  this.name = 'digest';
  this._secret = secret;
  this._validate = validate;
  this._realm = options.realm || 'Users';
  if (options.domain) {
    this._domain = (Array.isArray(options.domain)) ? options.domain : [ options.domain ];
  }
  this._opaque = options.opaque;
  this._algorithm = options.algorithm;
  if (options.qop) {
    this._qop = (Array.isArray(options.qop)) ? options.qop : [ options.qop ];
  }
}
function DigestStrategy(options, secret, validate) {
  if (typeof options == 'function') {
    validate = secret;
    secret = options;
    options = {};
  }
  if (!secret) throw new Error('HTTP Digest authentication strategy requires a secret function');
  
  passport.Strategy.call(this);
  this.name = 'digest';
  this._secret = secret;
  this._validate = validate;
  this._realm = options.realm || 'Users';
  if (options.domain) {
    this._domain = (Array.isArray(options.domain)) ? options.domain : [ options.domain ];
  }
  this._opaque = options.opaque;
  this._algorithm = options.algorithm;
  if (options.qop) {
    this._qop = (Array.isArray(options.qop)) ? options.qop : [ options.qop ];
  }
}
function DigestStrategy ( options , secret , validate ) { if ( typeof options == 'function' ) { validate = secret ; secret = options ; options = { } ; } if ( ! secret ) throw new Error ( 'HTTP Digest authentication strategy requires a secret function' ) ; passport . Strategy . call ( this ) ; this . name = 'digest' ; this . _secret = secret ; this . _validate = validate ; this . _realm = options . realm || 'Users' ; if ( options . domain ) { this . _domain = ( Array . isArray ( options . domain ) ) ? options . domain : [ options . domain ] ; } this . _opaque = options . opaque ; this . _algorithm = options . algorithm ; if ( options . qop ) { this . _qop = ( Array . isArray ( options . qop ) ) ? options . qop : [ options . qop ] ; } }
`DigestStrategy` constructor.

The HTTP Digest authentication strategy authenticates requests based on
username and digest credentials contained in the `Authorization` header
field.

Applications must supply a `secret` callback, which is used to look up the
user and corresponding password (aka shared secret) known to both the server
and the client, supplying them to the `done` callback as `user` and
`password`, respectively.  The strategy will use the password to compute the
response hash, failing authentication if it does not match that found in the
request. If the username is not valid, `user` should be set to false.  If an
exception occured, `err` should be set.

An optional `validate` callback can be supplied, which receives `params`
containing nonces that the server may want to track and validate.

Options:
- `realm`      authentication realm, defaults to "Users"
- `domain`     list of URIs that define the protection space
- `algorithm`  algorithm used to produce the digest (MD5 | MD5-sess)
- `qop`        list of quality of protection values support by the server (auth | auth-int) (recommended: auth)

`validate` params:
- `nonce`   unique string value specified by the server
- `cnonce`  opaque string value provided by the client
- `nc`      count of the number of requests (including the current request) that the client has sent with the nonce value
- `opaque`  string of data, specified by the server, which should be returned by the client in subsequent requests

Examples:

passport.use(new DigestStrategy({ qop: 'auth' },
function(username, done) {
// secret callback
User.findOne({ username: username }, function (err, user) {
if (err) { return done(err); }
return done(null, user, user.password);
});
},
function(params, done) {
// validate callback, check nonces in params...
done(err, true);
}
));

For further details on HTTP Basic authentication, refer to [RFC 2617: HTTP Authentication: Basic and Digest Access Authentication](http://tools.ietf.org/html/rfc2617)

@param {Object} options
@param {Function} secret
@param {Function} validate
@api public
DigestStrategy constructor .