Security

HMAC authentication with user sessions and account management

RealtimeSwitch uses HMAC-SHA256 authentication to secure WebSocket connections. The authentication system is based on three key concepts:

User Session

Unique identifier for each conversation session that maintains context and state throughout the interaction.

Account ID

Unique identifier for your account that provides access control and usage tracking.

HMAC Signature

Cryptographic hash generated using your account's secret key and session ID to ensure secure authentication.

HMAC Generation Examples

Here's how to generate the required HMAC-SHA256 signature in common programming languages:

const crypto = require('crypto');

function generateAuthHash(sessionId, secretKey) {
  return crypto
    .createHmac('sha256', secretKey)
    .update(sessionId, 'utf8')
    .digest('hex');
}

// Example usage
const accountId = '996-sdassds-86-asd';
const sessionId = 'test-session-browser';
const secretKey = 'secretkey-996';

const authHash = generateAuthHash(sessionId, secretKey);