code: function() {
          const flows = this._data.flows || [];
  
          // we've been given an email or we've already done an email part
          const haveEmail = Boolean(this._inputs.emailAddress) || Boolean(this._emailSid);
          const haveMsisdn = (
              Boolean(this._inputs.phoneCountry) &&
              Boolean(this._inputs.phoneNumber)
          );
  
          for (const flow of flows) {
              let flowHasEmail = false;
              let flowHasMsisdn = false;
              for (const stage of flow.stages) {
                  if (stage === EMAIL_STAGE_TYPE) {
                      flowHasEmail = true;
                  } else if (stage == MSISDN_STAGE_TYPE) {
                      flowHasMsisdn = true;
                  }
              }
  
              if (flowHasEmail == haveEmail && flowHasMsisdn == haveMsisdn) {
                  return flow;
              }
          }
          // Throw an error with a fairly generic description, but with more
          // information such that the app can give a better one if so desired.
          const err = new Error("No appropriate authentication flow found");
          err.name = 'NoAuthFlowFoundError';
          err.required_stages = [];
          if (haveEmail) err.required_stages.push(EMAIL_STAGE_TYPE);
          if (haveMsisdn) err.required_stages.push(MSISDN_STAGE_TYPE);
          err.available_flows = flows;
          throw err;
      }
docs: Pick one of the flows from the returned list
  If a flow using all of the inputs is found, it will
  be returned, otherwise, null will be returned.
  
  Only flows using all given inputs are chosen because it
  is likley to be surprising if the user provides a
  credential and it is not used. For example, for registration,
  this could result in the email not being used which would leave
  the account with no means to reset a password.
  
  @private
  @return {object} flow
  @throws {NoAuthFlowFoundError} If no suitable authentication flow can be found