implements NB protocol in JavaScript