lib/authorizer/digest.js
function (auth, response, done) {
        if (auth.get(DISABLE_RETRY_REQUEST) || !response) {
            return done(null, true);
        }

        var code,
            realm,
            nonce,
            qop,
            opaque,
            authHeader,
            authParams = {};

        code = response.code;
        authHeader = _getDigestAuthHeader(response.headers);

        // If code is forbidden or unauthorized, and an auth header exists,
        // we can extract the realm & the nonce, and replay the request.
        // todo: add response.is4XX, response.is5XX, etc in the SDK.
        if ((code === 401 || code === 403) && authHeader) {
            nonce = _extractField(authHeader.value, nonceRegex);
            realm = _extractField(authHeader.value, realmRegex);
            qop = _extractField(authHeader.value, qopRegex);
            opaque = _extractField(authHeader.value, opaqueRegex);

            authParams.nonce = nonce;
            authParams.realm = realm;
            opaque && (authParams.opaque = opaque);
            qop && (authParams.qop = qop);

            if (authParams.qop || auth.get(QOP)) {
                authParams.clientNonce = randomString(8);
                authParams.nonceCount = ONE;
            }

            // if all the auth parameters sent by server were already present in auth definition then we do not retry
            if (_.every(authParams, function (value, key) { return auth.get(key); })) {
                return done(null, true);
            }

            auth.set(authParams);

            return done(null, false);
        }

        done(null, true);
    }
function (auth, response, done) {
        if (auth.get(DISABLE_RETRY_REQUEST) || !response) {
            return done(null, true);
        }

        var code,
            realm,
            nonce,
            qop,
            opaque,
            authHeader,
            authParams = {};

        code = response.code;
        authHeader = _getDigestAuthHeader(response.headers);

        // If code is forbidden or unauthorized, and an auth header exists,
        // we can extract the realm & the nonce, and replay the request.
        // todo: add response.is4XX, response.is5XX, etc in the SDK.
        if ((code === 401 || code === 403) && authHeader) {
            nonce = _extractField(authHeader.value, nonceRegex);
            realm = _extractField(authHeader.value, realmRegex);
            qop = _extractField(authHeader.value, qopRegex);
            opaque = _extractField(authHeader.value, opaqueRegex);

            authParams.nonce = nonce;
            authParams.realm = realm;
            opaque && (authParams.opaque = opaque);
            qop && (authParams.qop = qop);

            if (authParams.qop || auth.get(QOP)) {
                authParams.clientNonce = randomString(8);
                authParams.nonceCount = ONE;
            }

            // if all the auth parameters sent by server were already present in auth definition then we do not retry
            if (_.every(authParams, function (value, key) { return auth.get(key); })) {
                return done(null, true);
            }

            auth.set(authParams);

            return done(null, false);
        }

        done(null, true);
    }
function ( auth , response , done ) { if ( auth . get ( DISABLE_RETRY_REQUEST ) || ! response ) { return done ( null , true ) ; } var code , realm , nonce , qop , opaque , authHeader , authParams = { } ; code = response . code ; authHeader = _getDigestAuthHeader ( response . headers ) ; // If code is forbidden or unauthorized, and an auth header exists, // we can extract the realm & the nonce, and replay the request. // todo: add response.is4XX, response.is5XX, etc in the SDK. if ( ( code === 401 || code === 403 ) && authHeader ) { nonce = _extractField ( authHeader . value , nonceRegex ) ; realm = _extractField ( authHeader . value , realmRegex ) ; qop = _extractField ( authHeader . value , qopRegex ) ; opaque = _extractField ( authHeader . value , opaqueRegex ) ; authParams . nonce = nonce ; authParams . realm = realm ; opaque && ( authParams . opaque = opaque ) ; qop && ( authParams . qop = qop ) ; if ( authParams . qop || auth . get ( QOP ) ) { authParams . clientNonce = randomString ( 8 ) ; authParams . nonceCount = ONE ; } // if all the auth parameters sent by server were already present in auth definition then we do not retry if ( _ . every ( authParams , function ( value , key ) { return auth . get ( key ) ; } ) ) { return done ( null , true ) ; } auth . set ( authParams ) ; return done ( null , false ) ; } done ( null , true ) ; }
Verifies whether the request was successfully authorized after being sent.

@param {AuthInterface} auth
@param {Response} response
@param {AuthHandlerInterface~authPostHookCallback} done
Verifies whether the request was successfully authorized after being sent .