Signed chat links
Create a signed link on your server, then use it as the URL of an iframe or WebView. The link identifies the viewer and can open or create a chat.
Create a link
import { Emby } from '@emby-chat/node-sdk';
const emby = new Emby({
id: process.env.EMBY_ID,
secret: process.env.EMBY_SECRET,
base_url: 'https://app.getchat.dev',
});
const link = emby.url({
user: { id: 'u-1', name: 'Alice' },
chat: {
id: 'support-42',
title: 'Support',
type: 'group',
create: true,
},
participants: [{ id: 'u-2', name: 'Bob' }],
extra: { lang: 'en', display_header: true },
});
user is required. A chat can be an object, an existing chat ID, or omitted when you want to open the messenger. Participants in signed links require a name; their picture, if provided, must be a URL.
The SDK signs url() links with HMAC-SHA256. Use the generated URL unchanged: editing signed fields invalidates the signature. A REST API token is not needed to generate links.
Set the viewer's rights
Add rights to user to control the viewer's actions:
const link = emby.url({
chat: 'support-42',
user: {
id: 'u-1',
name: 'Alice',
rights: {
send_messages: true,
edit_messages: 'my',
delete_messages: 'my',
pin_messages: 'for_everyone',
kick_users: false,
},
},
});
Per-chat participant rights can override these values. Setting an override to null restores the value from the signed link.
Customize the chat UI
The extra object passes UI settings to the chat, such as lang, display_header, display_input and message_max_length. The chat validates these settings; unknown keys are ignored.
Existing integrations
urlByChatId() is the older link builder and uses a different signing scheme. Keep it for integrations that already depend on it; use url() for new integrations.
See UrlOptions, UrlRecipient and UserRights for the public types.