function handleU2fSignRequest(messageSender, request, sendResponse) {
  var sentResponse = false;
  var queuedSignRequest;

  function sendErrorResponse(error) {
    sendResponseOnce(
        sentResponse, queuedSignRequest,
        makeU2fErrorResponse(request, error.errorCode, error.errorMessage),
        sendResponse);
  }

  function sendSuccessResponse(challenge, info, browserData) {
    var responseData = makeU2fSignResponseDataFromChallenge(challenge);
    addSignatureAndBrowserDataToResponseData(
        responseData, info, browserData, 'clientData');
    var response = makeU2fSuccessResponse(request, responseData);
    sendResponseOnce(sentResponse, queuedSignRequest, response, sendResponse);
  }

  var sender = createSenderFromMessageSender(messageSender);
  if (!sender) {
    sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
    return null;
  }
  if (sender.origin.indexOf('http://') == 0 && !HTTP_ORIGINS_ALLOWED) {
    sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
    return null;
  }

  queuedSignRequest = validateAndEnqueueSignRequest(
      sender, request, sendErrorResponse, sendSuccessResponse);
  return queuedSignRequest;
}
/**
 * Handles a U2F sign request.
 * @param {MessageSender} messageSender The message sender.
 * @param {Object} request The web page's sign request.
 * @param {Function} sendResponse Called back with the result of the sign.
 * @return {Closeable} Request handler that should be closed when the browser
 *     message channel is closed.
 */
Handles a U2F sign request.
@param {MessageSender} messageSender The message sender.
@param {Object} request The web page's sign request.
@param {Function} sendResponse Called back with the result of the sign.
@return {Closeable} Request handler that should be closed when the browser
message channel is closed.
Handles a U2F sign request . @param { MessageSender } messageSender The message sender . @param { Object } request The web page ' s sign request . @param { Function } sendResponse Called back with the result of the sign . @return { Closeable } Request handler that should be closed when the browser message channel is closed .
function handleU2fSignRequest(messageSender, request, sendResponse) {
  var sentResponse = false;
  var queuedSignRequest;
  function sendErrorResponse(error) {
    sendResponseOnce(
        sentResponse, queuedSignRequest,
        makeU2fErrorResponse(request, error.errorCode, error.errorMessage),
        sendResponse);
  }
  function sendSuccessResponse(challenge, info, browserData) {
    var responseData = makeU2fSignResponseDataFromChallenge(challenge);
    addSignatureAndBrowserDataToResponseData(
        responseData, info, browserData, 'clientData');
    var response = makeU2fSuccessResponse(request, responseData);
    sendResponseOnce(sentResponse, queuedSignRequest, response, sendResponse);
  }
  var sender = createSenderFromMessageSender(messageSender);
  if (!sender) {
    sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
    return null;
  }
  if (sender.origin.indexOf('http://') == 0 && !HTTP_ORIGINS_ALLOWED) {
    sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
    return null;
  }
  queuedSignRequest = validateAndEnqueueSignRequest(
      sender, request, sendErrorResponse, sendSuccessResponse);
  return queuedSignRequest;
}
function handleU2fSignRequest ( messageSender , request , sendResponse ) { var sentResponse = false ; var queuedSignRequest ; function sendErrorResponse ( error ) { sendResponseOnce ( sentResponse , queuedSignRequest , makeU2fErrorResponse ( request , error . errorCode , error . errorMessage ) , sendResponse ) ; } function sendSuccessResponse ( challenge , info , browserData ) { var responseData = makeU2fSignResponseDataFromChallenge ( challenge ) ; addSignatureAndBrowserDataToResponseData ( responseData , info , browserData , 'clientData' ) ; var response = makeU2fSuccessResponse ( request , responseData ) ; sendResponseOnce ( sentResponse , queuedSignRequest , response , sendResponse ) ; } var sender = createSenderFromMessageSender ( messageSender ) ; if ( ! sender ) { sendErrorResponse ( { errorCode : ErrorCodes . BAD_REQUEST } ) ; return null ; } if ( sender . origin . indexOf ( 'http://' ) == 0 && ! HTTP_ORIGINS_ALLOWED ) { sendErrorResponse ( { errorCode : ErrorCodes . BAD_REQUEST } ) ; return null ; } queuedSignRequest = validateAndEnqueueSignRequest ( sender , request , sendErrorResponse , sendSuccessResponse ) ; return queuedSignRequest ; }
Handles a U2F sign request.
Handles a U2F sign request .