3p/recaptcha.js
/**
 * Function to handle executing actions using the grecaptcha Object,
 * and sending the token back to the parent amp-recaptcha component
 *
 * Data Object will have the following fields
 * sitekey {string} - reCAPTCHA sitekey used to identify the site
 * action {string} - action to be dispatched with grecaptcha.execute
 * id {number} - id given to us by a counter in the recaptcha service
 *
 * @param {*} grecaptcha
 * @param {Object} data
 */
Function to handle executing actions using the grecaptcha Object,
and sending the token back to the parent amp-recaptcha component

Data Object will have the following fields
sitekey {string} - reCAPTCHA sitekey used to identify the site
action {string} - action to be dispatched with grecaptcha.execute
id {number} - id given to us by a counter in the recaptcha service

@param {*} grecaptcha
@param {Object} data
Function to handle executing actions using the grecaptcha Object and sending the token back to the parent amp - recaptcha component Data Object will have the following fields sitekey { string } - reCAPTCHA sitekey used to identify the site action { string } - action to be dispatched with grecaptcha . execute id { number } - id given to us by a counter in the recaptcha service @param { * } grecaptcha @param { Object } data
function actionTypeHandler(grecaptcha, data) {
  const executePromise = grecaptcha.execute(data.sitekey, {
    action: data.action,
  });
  executePromise.then(function(token) {
    iframeMessagingClient.sendMessage('amp-recaptcha-token', dict({
      'id': data.id,
      'token': token,
    }));
  }, function(err) {
    user().error(TAG, '%s', err.message);
    iframeMessagingClient.sendMessage('amp-recaptcha-error', dict({
      'id': data.id,
      'error': err.message,
    }));
  });
}
function actionTypeHandler ( grecaptcha , data ) { const executePromise = grecaptcha . execute ( data . sitekey , { action : data . action , } ) ; executePromise . then ( function ( token ) { iframeMessagingClient . sendMessage ( 'amp-recaptcha-token' , dict ( { 'id' : data . id , 'token' : token , } ) ) ; } , function ( err ) { user ( ) . error ( TAG , '%s' , err . message ) ; iframeMessagingClient . sendMessage ( 'amp-recaptcha-error' , dict ( { 'id' : data . id , 'error' : err . message , } ) ) ; } ) ; }
Function to handle executing actions using the grecaptcha Object,
 and sending the token back to the parent amp-recaptcha component
Function to handle executing actions using the grecaptcha Object and sending the token back to the parent amp - recaptcha component
// TODO: @torch2424: Verify message origin // TODO: @torch2424: Verify sitekey is the same as original // .then() promise pollyfilled by recaptcha api script /*OK*/ /*OK*/ /*OK*/