src/webfinger.js
function __fallbackChecks(err) {
      if ((self.config.uri_fallback) && (host !== 'webfist.org') && (uri_index !== URIS.length - 1)) { // we have uris left to try
        uri_index = uri_index + 1;
        return __call();
      } else if ((!self.config.tls_only) && (protocol === 'https')) { // try normal http
        uri_index = 0;
        protocol = 'http';
        return __call();
      } else if ((self.config.webfist_fallback) && (host !== 'webfist.org')) { // webfist attempt
        uri_index = 0;
        protocol = 'http';
        host = 'webfist.org';
        // webfist will
        // 1. make a query to the webfist server for the users account
        // 2. from the response, get a link to the actual webfinger json data
        //    (stored somewhere in control of the user)
        // 3. make a request to that url and get the json
        // 4. process it like a normal webfinger response
        var URL = __buildURL();
        self.__fetchJRD(URL, cb, function (data) { // get link to users JRD
          self.__processJRD(URL, data, cb, function (result) {
            if ((typeof result.idx.links.webfist === 'object') &&
                (typeof result.idx.links.webfist[0].href === 'string')) {
              self.__fetchJRD(result.idx.links.webfist[0].href, cb, function (JRD) {
                self.__processJRD(URL, JRD, cb, function (result) {
                  return cb(null, cb);
                });
              });
            }
          });
        });
      } else {
        return cb(err);
      }
    }
function __fallbackChecks(err) {
      if ((self.config.uri_fallback) && (host !== 'webfist.org') && (uri_index !== URIS.length - 1)) { // we have uris left to try
        uri_index = uri_index + 1;
        return __call();
      } else if ((!self.config.tls_only) && (protocol === 'https')) { // try normal http
        uri_index = 0;
        protocol = 'http';
        return __call();
      } else if ((self.config.webfist_fallback) && (host !== 'webfist.org')) { // webfist attempt
        uri_index = 0;
        protocol = 'http';
        host = 'webfist.org';
        // webfist will
        // 1. make a query to the webfist server for the users account
        // 2. from the response, get a link to the actual webfinger json data
        //    (stored somewhere in control of the user)
        // 3. make a request to that url and get the json
        // 4. process it like a normal webfinger response
        var URL = __buildURL();
        self.__fetchJRD(URL, cb, function (data) { // get link to users JRD
          self.__processJRD(URL, data, cb, function (result) {
            if ((typeof result.idx.links.webfist === 'object') &&
                (typeof result.idx.links.webfist[0].href === 'string')) {
              self.__fetchJRD(result.idx.links.webfist[0].href, cb, function (JRD) {
                self.__processJRD(URL, JRD, cb, function (result) {
                  return cb(null, cb);
                });
              });
            }
          });
        });
      } else {
        return cb(err);
      }
    }
function __fallbackChecks ( err ) { if ( ( self . config . uri_fallback ) && ( host !== 'webfist.org' ) && ( uri_index !== URIS . length - 1 ) ) { // we have uris left to try uri_index = uri_index + 1 ; return __call ( ) ; } else if ( ( ! self . config . tls_only ) && ( protocol === 'https' ) ) { // try normal http uri_index = 0 ; protocol = 'http' ; return __call ( ) ; } else if ( ( self . config . webfist_fallback ) && ( host !== 'webfist.org' ) ) { // webfist attempt uri_index = 0 ; protocol = 'http' ; host = 'webfist.org' ; // webfist will // 1. make a query to the webfist server for the users account // 2. from the response, get a link to the actual webfinger json data //    (stored somewhere in control of the user) // 3. make a request to that url and get the json // 4. process it like a normal webfinger response var URL = __buildURL ( ) ; self . __fetchJRD ( URL , cb , function ( data ) { // get link to users JRD self . __processJRD ( URL , data , cb , function ( result ) { if ( ( typeof result . idx . links . webfist === 'object' ) && ( typeof result . idx . links . webfist [ 0 ] . href === 'string' ) ) { self . __fetchJRD ( result . idx . links . webfist [ 0 ] . href , cb , function ( JRD ) { self . __processJRD ( URL , JRD , cb , function ( result ) { return cb ( null , cb ) ; } ) ; } ) ; } } ) ; } ) ; } else { return cb ( err ) ; } }
control flow for failures, what to do in various cases, etc.
control flow for failures what to do in various cases etc .