Docs

@klorad/protocols

Integration adapters for real equipment. MQTT (readings and Twin commands), signed webhooks, REST polling.

import { webhookSource, signWebhook, verifyWebhook, restSource } from "@klorad/protocols";
import { mqttConnection, jsonPayload } from "@klorad/protocols/mqtt";

Node 20 or newer. Every adapter is an ObservationSource for connectSource; mqttConnection is also an Actuator for createInteraction.

mqttConnection

Prop

Type

Returns MqttConnection: id, source, start(sink), send(command), close(). jsonPayload(payload) decodes a UTF-8 JSON payload.

webhookSource

Prop

Type

Returns WebhookSource: an ObservationSource with handle(request: Request): Promise<Response>. signWebhook(secret, timestamp, body) returns the signature header value; verifyWebhook(secret, timestamp, body, signature) checks one.

restSource

Prop

Type

Something wrong or unclear? Tell us.