ha1Compute = function (algorithm, user, realm, pass, nonce, cnonce) {
    var ha1 = md5(user + ':' + realm + ':' + pass)
    if (algorithm && algorithm.toLowerCase() === 'md5-sess') {
      return md5(ha1 + ':' + nonce + ':' + cnonce)
    } else {
      return ha1
    }
  }
RFC 2617: handle both MD5 and MD5-sess algorithms.

If the algorithm directive's value is "MD5" or unspecified, then HA1 is
  HA1=MD5(username:realm:password)
If the algorithm directive's value is "MD5-sess", then HA1 is
  HA1=MD5(MD5(username:realm:password):nonce:cnonce)