lib/auth/request-dh-params.js
function requestDHParams(callback, context) {
    var resPQ = context.resPQ;
    mtproto.service.req_DH_params({
        props: {
            nonce: resPQ.nonce,
            server_nonce: resPQ.server_nonce,
            p: context.pBuffer,
            q: context.qBuffer,
            public_key_fingerprint: context.fingerprint,
            encrypted_data: context.encryptedData
        },
        channel: context.channel,
        callback: function (ex, serverDHParams, duration) {
            if (ex) {
                logger.error(ex);
                if (callback) {
                    callback(ex);
                }
            } else {
                if (serverDHParams.instanceOf('mtproto.type.Server_DH_params_ok')) {
                    if (logger.isDebugEnabled()) {
                        logger.debug('\'Server_DH_params_ok\' received from Telegram.');
                    }
                    context.serverDHParams = serverDHParams;
                    context.reqDHDuration = duration;
                    callback(null, context);
                } else if (serverDHParams.instanceOf('mtproto.type.Server_DH_params_ko')) {
                    logger.warn('\'Server_DH_params_ko\' received from Telegram!');
                    callback(createError(JSON.stringify(serverDHParams), 'EDHPARAMKO'));
                } else {
                    var msg = 'Unknown error received from Telegram!';
                    logger.error(msg);
                    callback(createError(msg, 'EUNKNOWN'));
                }
            }
        }
    });
}
function requestDHParams(callback, context) {
    var resPQ = context.resPQ;
    mtproto.service.req_DH_params({
        props: {
            nonce: resPQ.nonce,
            server_nonce: resPQ.server_nonce,
            p: context.pBuffer,
            q: context.qBuffer,
            public_key_fingerprint: context.fingerprint,
            encrypted_data: context.encryptedData
        },
        channel: context.channel,
        callback: function (ex, serverDHParams, duration) {
            if (ex) {
                logger.error(ex);
                if (callback) {
                    callback(ex);
                }
            } else {
                if (serverDHParams.instanceOf('mtproto.type.Server_DH_params_ok')) {
                    if (logger.isDebugEnabled()) {
                        logger.debug('\'Server_DH_params_ok\' received from Telegram.');
                    }
                    context.serverDHParams = serverDHParams;
                    context.reqDHDuration = duration;
                    callback(null, context);
                } else if (serverDHParams.instanceOf('mtproto.type.Server_DH_params_ko')) {
                    logger.warn('\'Server_DH_params_ko\' received from Telegram!');
                    callback(createError(JSON.stringify(serverDHParams), 'EDHPARAMKO'));
                } else {
                    var msg = 'Unknown error received from Telegram!';
                    logger.error(msg);
                    callback(createError(msg, 'EUNKNOWN'));
                }
            }
        }
    });
}
function requestDHParams ( callback , context ) { var resPQ = context . resPQ ; mtproto . service . req_DH_params ( { props : { nonce : resPQ . nonce , server_nonce : resPQ . server_nonce , p : context . pBuffer , q : context . qBuffer , public_key_fingerprint : context . fingerprint , encrypted_data : context . encryptedData } , channel : context . channel , callback : function ( ex , serverDHParams , duration ) { if ( ex ) { logger . error ( ex ) ; if ( callback ) { callback ( ex ) ; } } else { if ( serverDHParams . instanceOf ( 'mtproto.type.Server_DH_params_ok' ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( '\'Server_DH_params_ok\' received from Telegram.' ) ; } context . serverDHParams = serverDHParams ; context . reqDHDuration = duration ; callback ( null , context ) ; } else if ( serverDHParams . instanceOf ( 'mtproto.type.Server_DH_params_ko' ) ) { logger . warn ( '\'Server_DH_params_ko\' received from Telegram!' ) ; callback ( createError ( JSON . stringify ( serverDHParams ) , 'EDHPARAMKO' ) ) ; } else { var msg = 'Unknown error received from Telegram!' ; logger . error ( msg ) ; callback ( createError ( msg , 'EUNKNOWN' ) ) ; } } } } ) ; }
Request server DH parameters
Request server DH parameters