node_modules/mariadb/lib/cmd/handshake/handshake.js
/**
   * Handle authentication switch request : dispatch to plugin handler.
   *
   * @param packet  packet
   * @param out     output writer
   * @param opts    options
   * @param info    connection information
   */
Handle authentication switch request : dispatch to plugin handler.
@param packet  packet
@param out     output writer
@param opts    options
@param info    connection information
Handle authentication switch request : dispatch to plugin handler . @param packet packet @param out output writer @param opts options @param info connection information
dispatchAuthSwitchRequest(packet, out, opts, info) {
    let pluginName, pluginData;
    if (info.clientCapabilities & Capabilities.PLUGIN_AUTH) {
      packet.skip(1); 
      if (packet.remaining()) {
        pluginName = packet.readStringNullEnded();
        pluginData = packet.readBufferRemaining();
      } else {
        pluginName = 'mysql_old_password';
        pluginData = info.seed.slice(0, 8);
      }
    } else {
      pluginName = packet.readStringNullEnded('cesu8');
      pluginData = packet.readBufferRemaining();
    }
    try {
      this.plugin = Handshake.pluginHandler(
        pluginName,
        this.plugin.sequenceNo,
        this.plugin.compressSequenceNo,
        pluginData,
        info,
        opts,
        out,
        this.resolve,
        this.reject,
        this.handshakeResult.bind(this)
      );
    } catch (err) {
      this.reject(err);
      return;
    }
    if (!this.plugin) {
      this.reject(
        Errors.createError(
          "Client does not support authentication protocol '" +
            pluginName +
            "' requested by server. ",
          true,
          info,
          '08004',
          Errors.ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED
        )
      );
    } else {
      this._addCommand(this.plugin, false);
    }
  }
dispatchAuthSwitchRequest ( packet , out , opts , info ) { let pluginName , pluginData ; if ( info . clientCapabilities & Capabilities . PLUGIN_AUTH ) { packet . skip ( 1 ) ; if ( packet . remaining ( ) ) { pluginName = packet . readStringNullEnded ( ) ; pluginData = packet . readBufferRemaining ( ) ; } else { pluginName = 'mysql_old_password' ; pluginData = info . seed . slice ( 0 , 8 ) ; } } else { pluginName = packet . readStringNullEnded ( 'cesu8' ) ; pluginData = packet . readBufferRemaining ( ) ; } try { this . plugin = Handshake . pluginHandler ( pluginName , this . plugin . sequenceNo , this . plugin . compressSequenceNo , pluginData , info , opts , out , this . resolve , this . reject , this . handshakeResult . bind ( this ) ) ; } catch ( err ) { this . reject ( err ) ; return ; } if ( ! this . plugin ) { this . reject ( Errors . createError ( "Client does not support authentication protocol '" + pluginName + "' requested by server. " , true , info , '08004' , Errors . ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED ) ) ; } else { this . _addCommand ( this . plugin , false ) ; } }
Handle authentication switch request : dispatch to plugin handler.
Handle authentication switch request : dispatch to plugin handler .
//header //AuthSwitchRequest packet. //OldAuthSwitchRequest