High-level messaging & socket patterns with optionional encryption implemented in pure js