Moved JS authentication methods to seperate lib file