lib/auth/set-client-dh-params.js
function setClientDHParams(callback, context) {
    mtproto.service.set_client_DH_params({
        props: {
            nonce: context.resPQ.nonce,
            server_nonce: context.resPQ.server_nonce,
            encrypted_data: context.encryptClientDHInnerData
        },
        channel: context.channel,
        callback: function (ex, setClientDHParamsAnswer) {
            if (ex) {
                logger.error(ex);
                if (callback) {
                    callback(ex);
                }
            } else {
                if (setClientDHParamsAnswer.instanceOf('mtproto.type.Dh_gen_ok')) {
                    if (logger.isDebugEnabled()) {
                        logger.debug('\'Dh_gen_ok\' received from Telegram.');
                    }
                    context.setClientDHParamsAnswer = setClientDHParamsAnswer;
                    flow.runSeries([
                        calculateAuthKeyValue,
                        createAuthKeyID,
                        checkNonceMatch,
                        createAuthKey
                    ], callback, context);
                } else if (setClientDHParamsAnswer.instanceOf('mtproto.type.Dh_gen_retry')) {
                    logger.warn('\'Dh_gen_retry\' received from Telegram!');
                    callback(createError(JSON.stringify(setClientDHParamsAnswer), 'EDHPARAMRETRY'));
                } else if (setClientDHParamsAnswer.instanceOf('mtproto.type.Dh_gen_fail')) {
                    logger.warn('\'Dh_gen_fail\' received from Telegram!');
                    callback(createError(JSON.stringify(setClientDHParamsAnswer), 'EDHPARAMFAIL'));
                } else {
                    var msg = 'Unknown error received from Telegram!';
                    logger.error(msg);
                    callback(createError(msg, 'EUNKNOWN'));
                }
            }
        }
    });
}
function setClientDHParams(callback, context) {
    mtproto.service.set_client_DH_params({
        props: {
            nonce: context.resPQ.nonce,
            server_nonce: context.resPQ.server_nonce,
            encrypted_data: context.encryptClientDHInnerData
        },
        channel: context.channel,
        callback: function (ex, setClientDHParamsAnswer) {
            if (ex) {
                logger.error(ex);
                if (callback) {
                    callback(ex);
                }
            } else {
                if (setClientDHParamsAnswer.instanceOf('mtproto.type.Dh_gen_ok')) {
                    if (logger.isDebugEnabled()) {
                        logger.debug('\'Dh_gen_ok\' received from Telegram.');
                    }
                    context.setClientDHParamsAnswer = setClientDHParamsAnswer;
                    flow.runSeries([
                        calculateAuthKeyValue,
                        createAuthKeyID,
                        checkNonceMatch,
                        createAuthKey
                    ], callback, context);
                } else if (setClientDHParamsAnswer.instanceOf('mtproto.type.Dh_gen_retry')) {
                    logger.warn('\'Dh_gen_retry\' received from Telegram!');
                    callback(createError(JSON.stringify(setClientDHParamsAnswer), 'EDHPARAMRETRY'));
                } else if (setClientDHParamsAnswer.instanceOf('mtproto.type.Dh_gen_fail')) {
                    logger.warn('\'Dh_gen_fail\' received from Telegram!');
                    callback(createError(JSON.stringify(setClientDHParamsAnswer), 'EDHPARAMFAIL'));
                } else {
                    var msg = 'Unknown error received from Telegram!';
                    logger.error(msg);
                    callback(createError(msg, 'EUNKNOWN'));
                }
            }
        }
    });
}
function setClientDHParams ( callback , context ) { mtproto . service . set_client_DH_params ( { props : { nonce : context . resPQ . nonce , server_nonce : context . resPQ . server_nonce , encrypted_data : context . encryptClientDHInnerData } , channel : context . channel , callback : function ( ex , setClientDHParamsAnswer ) { if ( ex ) { logger . error ( ex ) ; if ( callback ) { callback ( ex ) ; } } else { if ( setClientDHParamsAnswer . instanceOf ( 'mtproto.type.Dh_gen_ok' ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( '\'Dh_gen_ok\' received from Telegram.' ) ; } context . setClientDHParamsAnswer = setClientDHParamsAnswer ; flow . runSeries ( [ calculateAuthKeyValue , createAuthKeyID , checkNonceMatch , createAuthKey ] , callback , context ) ; } else if ( setClientDHParamsAnswer . instanceOf ( 'mtproto.type.Dh_gen_retry' ) ) { logger . warn ( '\'Dh_gen_retry\' received from Telegram!' ) ; callback ( createError ( JSON . stringify ( setClientDHParamsAnswer ) , 'EDHPARAMRETRY' ) ) ; } else if ( setClientDHParamsAnswer . instanceOf ( 'mtproto.type.Dh_gen_fail' ) ) { logger . warn ( '\'Dh_gen_fail\' received from Telegram!' ) ; callback ( createError ( JSON . stringify ( setClientDHParamsAnswer ) , 'EDHPARAMFAIL' ) ) ; } else { var msg = 'Unknown error received from Telegram!' ; logger . error ( msg ) ; callback ( createError ( msg , 'EUNKNOWN' ) ) ; } } } } ) ; }
Set client DH parameters
Set client DH parameters