/** * Create a configured MQTT client for a Yoto device * @param {YotoMqttOptions} options - MQTT connection options * @returns {YotoMqttClient} Configured Yoto MQTT client * @throws {Error} If required options are missing * * @example * ```javascript * import { createYotoMqttClient } from 'yoto-nodejs-client/lib/mqtt' * * const client = createYotoMqttClient({ * deviceId: 'abc123', * token, * clientId: 'my-unique-client-id' * }) * * client.on('events', (message) => { * console.log('Playing:', message.trackTitle) * }) * * await client.connect() * ``` * * @example * ```javascript * // Disable automatic reconnection * const client = createYotoMqttClient({ * deviceId: 'abc123', * token, * clientId: 'my-unique-client-id', * mqttOptions: { * reconnectPeriod: 0, // Disable auto-reconnect (default is 5000ms) * connectTimeout: 30000 // 30 second connection timeout * } * }) * ``` */ export function createYotoMqttClient(options: YotoMqttOptions): YotoMqttClient; /** * MQTT.js client options that can be passed to createYotoMqttClient */ export type MqttClientOptions = Partial; export type YotoMqttOptions = { /** * - Device ID to connect to */ deviceId: string; /** * - RefreshableToken instance used to supply the current JWT. Enables auto-updating auth on reconnect via transformWsUrl. */ token: RefreshableToken; /** * - Stable unique session ID suffix used to avoid collisions across multiple clients/processes. Used to build the MQTT clientId: DASH${deviceId}${sessionId} (non-alphanumeric characters are stripped). (MQTT calls this clientId, but we call it sessionId to not confuse it with the oauth clientId) */ sessionId?: string; /** * - Prefix for MQTT client ID (default: 'DASH') */ clientIdPrefix?: string; /** * - MQTT broker URL */ brokerUrl?: string; /** * - MQTT broker port */ port?: number; /** * - Auto-subscribe to device topics on connect */ autoSubscribe?: boolean; /** * - Additional MQTT.js client options (defaults: reconnectPeriod=5000, reconnectOnConnackError=true, keepalive=300, clean=false; cannot override: clientId, username, password, protocol, ALPNProtocols; transformWsUrl is wrapped to keep auth current) */ mqttOptions?: MqttClientOptions; }; import { YotoMqttClient } from './client.js'; import mqtt from 'mqtt'; import type { RefreshableToken } from '../token.js'; //# sourceMappingURL=factory.d.ts.map