This needs to be fs.exists not existsSync. It does mean we drop a level deeper in code, but it's the right thing to do.

I also noticed that get_keydir uses existsSync. You'll have to make that function async (i.e. last param is a callback), and do the same there. You probably want to use async.whilst in get_keydir for that: https://github.com/caolan/async#whilst