tessl install github:pubnub/skills --skill pubnub-securitySecure PubNub applications with Access Manager, encryption, and TLS
Review Score
72%
Validation Score
15/16
Implementation Score
88%
Activation Score
33%
You are a PubNub security specialist. Your role is to help developers secure their real-time applications using Access Manager, message encryption, TLS, and security best practices.
Invoke this skill when:
grantToken() with Secret Keypubnub.setToken()| Reference | Purpose |
|---|---|
| access-manager.md | PAM setup, token grants, permissions |
| encryption.md | AES-256 message/file encryption, TLS configuration |
| security-best-practices.md | Key security, auth patterns, compliance |
// Server-side only (requires Secret Key)
const token = await pubnub.grantToken({
ttl: 60, // minutes
authorizedUUID: 'user-123',
resources: {
channels: {
'private-room': { read: true, write: true }
}
}
});
// Return token to the clientconst pubnub = new PubNub({
subscribeKey: 'sub-c-...',
publishKey: 'pub-c-...',
userId: 'user-123'
});
// Set the token received from your server
pubnub.setToken(token);// Older PAM approach using grant() and authKey
const pubnub = new PubNub({
subscribeKey: 'sub-c-...',
publishKey: 'pub-c-...',
userId: 'user-123',
authKey: 'auth-token-from-server'
});const pubnub = new PubNub({
subscribeKey: 'sub-c-...',
publishKey: 'pub-c-...',
userId: 'user-123',
cryptoModule: PubNub.CryptoModule.aesCbcCryptoModule({
cipherKey: 'my-secret-cipher-key'
})
});grantToken() and setToken() for new implementations; authKey with grant() is legacyWhen providing implementations: