Skip to navigation

mintHandle

View as MarkdownOpen in Claude

Issues a signed handle for a conversation. The browser never names a conversation directly: if it could, a publishable key and a guessed id would be enough to continue someone else’s chat. With signing, a caller can only present handles this gateway issued.

A handle is valid for handleTtl seconds and is signed with the gateway’s secret. readHandle() verifies one and returns the conversation id.

Parameters

conversationId
string

The conversation to name. A new random id, prefixed chat-, when omitted or empty.

Returns

string — the handle.

Examples

import { ChatGateway } from '@signalwire/sdk';
const gateway = new ChatGateway({
configUrl: 'https://bayview-taxi.example.com/dispatch',
key: '<YOUR_PUBLISHABLE_KEY>',
secret: process.env.SIGNALWIRE_CHAT_GATEWAY_SECRET,
});
const fresh = gateway.mintHandle();
const named = gateway.mintHandle('chat-8f21');
console.log(gateway.readHandle(fresh)); // chat-<random>
console.log(gateway.readHandle(named)); // chat-8f21