Express basicAuth: Async vs Syn

I was wondering what the difference is between the async and sync callback patterns for basicAuth in connect.js middelware.

I understand the nodejs is on a single threaded event loop, but the synch "callback" is a callback function, and is thus asynchronous. So I don't understand what the difference is.

In both cases your callback is actually called synchronously by basicAuth, but in the asynchronous case you call the fn parameter to your callback to deliver the result back to basicAuth instead of returning the result from your callback function.

Like shown in the canonical example code from here.

// Sync case, where the callback function returns true/false
connect(
  connect.basicAuth(function(user, pass){
    return 'tj' == user & 'wahoo' == pass;
  })
);

// Async case, where User.authenticate uses an asynchronous call to determine the validity
// of the user, and fn is called by that function to deliver the true/false result back to
// basicAuth once the async call completes.
connect(
  connect.basicAuth(function(user, pass, fn){
    User.authenticate({ user: user, pass: pass }, fn);
  })
);