lib/pxproxy.js
function getClient(req, config, ip, cb) {
    let res = {};
    if (!config.FIRST_PARTY_ENABLED) {
        res = {
            status: 200,
            header: {key: 'Content-Type', value:'application/javascript'},
            body: ''
        };
        return cb(null, res);
    } else {
        const clientRequestUri = `/${config.PX_APP_ID}/main.min.js`;
        config.logger.debug(`Forwarding request from ${req.originalUrl.toLowerCase()} to client at ${config.CLIENT_HOST}${clientRequestUri}`);
        const callData = {
            url: `https://${config.CLIENT_HOST}${clientRequestUri}`,
            headers: pxUtil.filterSensitiveHeaders(req.headers, config.SENSITIVE_HEADERS),
            timeout: config.API_TIMEOUT_MS
        };
        callData.headers['host'] = config.CLIENT_HOST;
        callData.headers[config.ENFORCER_TRUE_IP_HEADER] = ip;
        callData.headers[config.FIRST_PARTY_HEADER] = 1;
        request.get(callData, config, (error, response) => {
            if (error || !response) {
                config.logger.error(`Error while fetching first party client: ${error}`);
            }

            response = response || {statusCode: 200, headers: {}};
            res = {
                status: response.statusCode,
                headers: response.headers,
                body: response.body || ''
            };
            return cb(null, res);
        });
    }
    return;
}
function getClient(req, config, ip, cb) {
    let res = {};
    if (!config.FIRST_PARTY_ENABLED) {
        res = {
            status: 200,
            header: {key: 'Content-Type', value:'application/javascript'},
            body: ''
        };
        return cb(null, res);
    } else {
        const clientRequestUri = `/${config.PX_APP_ID}/main.min.js`;
        config.logger.debug(`Forwarding request from ${req.originalUrl.toLowerCase()} to client at ${config.CLIENT_HOST}${clientRequestUri}`);
        const callData = {
            url: `https://${config.CLIENT_HOST}${clientRequestUri}`,
            headers: pxUtil.filterSensitiveHeaders(req.headers, config.SENSITIVE_HEADERS),
            timeout: config.API_TIMEOUT_MS
        };
        callData.headers['host'] = config.CLIENT_HOST;
        callData.headers[config.ENFORCER_TRUE_IP_HEADER] = ip;
        callData.headers[config.FIRST_PARTY_HEADER] = 1;
        request.get(callData, config, (error, response) => {
            if (error || !response) {
                config.logger.error(`Error while fetching first party client: ${error}`);
            }

            response = response || {statusCode: 200, headers: {}};
            res = {
                status: response.statusCode,
                headers: response.headers,
                body: response.body || ''
            };
            return cb(null, res);
        });
    }
    return;
}
function getClient ( req , config , ip , cb ) { let res = { } ; if ( ! config . FIRST_PARTY_ENABLED ) { res = { status : 200 , header : { key : 'Content-Type' , value : 'application/javascript' } , body : '' } ; return cb ( null , res ) ; } else { const clientRequestUri = ` ${ config . PX_APP_ID } ` ; config . logger . debug ( ` ${ req . originalUrl . toLowerCase ( ) } ${ config . CLIENT_HOST } ${ clientRequestUri } ` ) ; const callData = { url : ` ${ config . CLIENT_HOST } ${ clientRequestUri } ` , headers : pxUtil . filterSensitiveHeaders ( req . headers , config . SENSITIVE_HEADERS ) , timeout : config . API_TIMEOUT_MS } ; callData . headers [ 'host' ] = config . CLIENT_HOST ; callData . headers [ config . ENFORCER_TRUE_IP_HEADER ] = ip ; callData . headers [ config . FIRST_PARTY_HEADER ] = 1 ; request . get ( callData , config , ( error , response ) => { if ( error || ! response ) { config . logger . error ( ` ${ error } ` ) ; } response = response || { statusCode : 200 , headers : { } } ; res = { status : response . statusCode , headers : response . headers , body : response . body || '' } ; return cb ( null , res ) ; } ) ; } return ; }
getClient - process the proxy request to get the client file from PX servers.

@param {object} req - the request object.
@param {object} config - the PerimeterX config object.
@param {string} ip - the ip that initiated the call.
@param {function} cb - the callback function to call at the end of the process.

@return {function} the callback function passed as param with the server response (client file) or error.
getClient - process the proxy request to get the client file from PX servers .