Does WebRTC have any sort of extension mechanism whereby I can drop in my own version of NAT traversal logic?
Speaking from past experience, STUN and ICE are OK, but they got the whole process fundamentally wrong. They let the clients drive the traversal process. This is substantially inferior to letting a dedicated mediating server do that instead. I did that with one of my past projects and it helped with connecting peers in a large number of obscure scenarios.
ICE/STUN (which is used by WebRTC and thus PeerJS) support NAT traversal in all cases but a pair of symmetric NATs, which means some single digit percentage of connections will not work. For those cases, WebRTC/PeerJS support using a TURN server which proxies the data, not ideal but it allows the library to work.
Q1. Does this support connecting to a peer behind a NAT device?
Q2. Does this support connecting two peers each behind its own NAT?
Because a vast majority of real world cases will fall into either of these two categories.