validateToken

View as MarkdownOpen in Claude

Validate a token against the expected call ID and function name. Checks the HMAC signature, expiration, function name match, and call ID match.

Parameters

callId
stringRequired

The expected call ID.

functionName
stringRequired

The expected function name.

token
stringRequired

The base64url-encoded token to validate.

Returns

booleantrue if the token is valid and not expired.

Example

1import { SessionManager } from '@signalwire/sdk';
2
3const sm = new SessionManager();
4const token = sm.generateToken('get_weather', 'call-abc123');
5const valid = sm.validateToken('call-abc123', 'get_weather', token);
6console.log('Valid:', valid); // true