code: function getFactorConstructor(/* factor */) {
    var data = arguments[0];
  
    if (!data || (typeof data.type === 'undefined')) {
      throw new Error('Factor instances must have a defined type');
    }
  
    var type = data.type.toLowerCase();
  
    switch (type) {
    case 'sms':
      return SmsFactor;
    case 'google-authenticator':
      return GoogleAuthenticatorFactor;
    default:
      return Factor;
    }
  }
docs: Retrieves the constructor for a correct {@link Factor} instance ({@link SmsFactor} or
  {@link GoogleAuthenticatorFactor}) for corresponding JSON data for the factor.
  
  @private
  
  @param {FactorData} factor
  The data for the factor object
  
  @throws Error If the type is not defined or if it is not a valid type (SMS or google-authenticator)