Secure PubNub applications with Access Manager, encryption, and TLS
Does it follow best practices?
Evaluation — 95%
↑ 1.13xAgent success when using this tile
Validation for skill structure
A fintech company runs a trading platform where brokers and clients communicate in real time. They use PubNub for three types of channels: public market commentary (no encryption needed), private broker-client conversations (moderate sensitivity), and trade execution confirmations (highly sensitive financial data). The compliance team has mandated that private and financial messages must be encrypted end-to-end so that even PubNub's infrastructure cannot read the message contents.
The engineering team needs a Node.js module that creates properly configured PubNub client instances for each security tier. The module should also include a utility to generate strong encryption keys, since the team has been using weak, manually-chosen strings as keys and the security audit flagged this as a risk.
Create a file called secure-messaging.js containing:
generateCipherKey() that produces a cryptographically strong key suitable for AES-256 encryptioncreatePublicClient(userId) that returns a PubNub instance for unencrypted public channelscreatePrivateClient(userId) that returns a PubNub instance configured with encryption for private broker-client conversations, using a key passed as parametercreateFinancialClient(userId) that returns a PubNub instance configured with encryption for trade execution channels, using a different key passed as parameterAlso create a file called key-setup.js that demonstrates generating keys for each security tier and creating the three client types for a sample user.