title: AWS Cognito - custom challenge not triggered
body: <p>I'm defining a custom challenge on user authentication. I created a few lambdas:</p>
  
  <h3>tutoring-define-auth-challenge</h3>
  
  <pre><code>"use strict";
  
  exports.handler = (event, context, callback) =&gt; {
      // throw new Error("tutoring-define-auth-challenge");
      if (event.request.session.length == 1 &amp;&amp; event.request.session[0].challengeName == 'SRP_A') {
          event.response.issueTokens = false;
          event.response.failAuthentication = false;
          event.response.challengeName = 'PASSWORD_VERIFIER';
      } else if (event.request.session.length == 2 &amp;&amp; event.request.session[1].challengeName == 'PASSWORD_VERIFIER' &amp;&amp; event.request.session[1].challengeResult == true) {
          event.response.issueTokens = false;
          event.response.failAuthentication = false;
          event.response.challengeName = 'CUSTOM_CHALLENGE';
      } else if (event.request.session.length == 3 &amp;&amp; event.request.session[2].challengeName == 'CUSTOM_CHALLENGE' &amp;&amp; event.request.session[2].challengeResult == true) {
          event.response.issueTokens = true;
          event.response.failAuthentication = false;
      } else {
          event.response.issueTokens = false;
          event.response.failAuthentication = true;
      }
  
      // Return to Amazon Cognito
      callback(null, event);
  }
  
  </code></pre>
  
  <h3>tutoring-create-auth-challenge</h3>
  
  <pre><code>"use strict";
  
  const publicKey = require('./public');
  exports.handler = async (event) =&gt; {
      //throw new Error("tutoring-create-auth-challenge");
      event.response.privateChallengeParameters = { key: publicKey.key };
      return event;
  };
  
  </code></pre>
  
  <p>and configured them as triggers in the user pools
  <a href="https://i.stack.imgur.com/gwWPD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gwWPD.png" alt="enter image description here"></a></p>
  
  <p>The problem is that those lambdas aren't triggered. I added errors in each of them (see commented out code) but I was able to register and log in without any problem.</p>
  
  <p>What I want to do is add a new challenge with checking a custom JWT token (instead of verification code sent by email).</p>
  
  <p>What else do I have to do to make it work? I checked cloudwatch and could be able to find only logs from manual lambda's executions.</p>