Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

the-things-stack-webhooks

БесплатноЗапускает вложенные скриптыНе проверен

Receive and authenticate The Things Stack webhooks (The Things Network and The Things Industries LoRaWAN Application Server). Use when creating a custom…

hookdeckот hookdeck★ 104 звезды на GitHub

Об этом скилле

The Things Stack Webhooks

The Things Stack (the LoRaWAN network server behind The Things Network and The Things Industries) can send each application's messages to an HTTP endpoint: uplinks, join-accepts, downlink events, location results. You add a webhook under your application's Integrations > Webhooks in the Console. The Application Server always sends POST requests with a JSON body.

When to Use This Skill

  • How do I receive The Things Stack (TTN) uplinks with a webhook?
  • How do I authenticate The Things Stack webhook requests? (there's no signature)
  • What does "Request authentication" send? (Authorization: Basic …)
  • How do I tell uplink, join-accept and downlink messages apart?
  • What is the X-Downlink-Apikey header?

Authentication (core)

The Things Stack doesn't sign webhooks. Check Request authentication on the webhook and enter a username and password: the Console stores an Authorization header that the Application Server sends with every request.

Authorization: Basic base64(<username>:<password>)

The docs call it "Authentication: Basic ", but the Console code sets Authorization (headers.Authorization = 'Basic ' + btoa(username + ':' + password)).

const crypto = require('crypto');

const safeEqual = (a, b) => crypto.timingSafeEqual(
  crypto.createHash('sha256').update(a).digest(),
  crypto.createHash('sha256').update(b).digest());

function verifyBasicAuth(authorization, username, password) {
  const match = /^Basic\s+([A-Za-z0-9+/]+={0,2})\s*$/i.exec(String(authorization || ''));
  if (!match || !username || !password) return false;
  const decoded = Buffer.from(match[1], 'base64').toString('utf8');
  const i = decoded.indexOf(':');                    // split at the FIRST colon
  if (i < 0) return false;
  const userOk = safeEqual(decoded.slice(0, i), username);
  const passOk = safeEqual(decoded.slice(i + 1), password);
  return userOk && passOk;
}
  • Compare both values in constant time, and evaluate both before combining, so a wrong username doesn't return faster.
  • The password can contain :. Split at the first colon only.
  • Missing or wrong credentials: 401. Credentials not configured: 500.
  • Webhooks made with templates, the CLI or the API can set any header, so Authorization is just a stored header. Without Request authentication, nothing authenticates the request: use HTTPS and a hard-to-guess path at the least.

For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.

Hookdeck: Hookdeck's The Things Stack source type (THE_THINGS_STACK) checks the basic auth credentials. Enter the same username and password as in Request authentication.

Messages

Every message has end_device_ids, correlation_ids and received_at, plus one message object named after its type:

{
  "end_device_ids": { "device_id": "dev1", "application_ids": { "application_id": "app1" }, "dev_eui": "0004A30B001C0530", "dev_addr": "00BCB929" },
  "correlation_ids": ["as:up:01E0WZGT6Y7657CPFPE5WEYDSQ"],
  "received_at": "2020-02-12T15:15:46.014773143Z",
  "uplink_message": {
    "f_port": 1, "f_cnt": 1, "frm_payload": "gkHe",
    "decoded_payload": { "temperature": 1.0, "luminosity": 0.64 },
    "rx_metadata": [{ "gateway_ids": { "gateway_id": "gtw1" }, "rssi": -35, "snr": 5.2 }]
  }
}
Message object Sent for
uplink_message An uplink. frm_payload is base64; decoded_payload appears when a payload formatter is set
uplink_normalized A normalized uplink
join_accept A device joined
downlink_ack, downlink_nack, downlink_sent, downlink_failed, downlink_queued, downlink_queue_invalidated Downlink events
location_solved A location result
service_data Service data

Fields whose value is "", 0 or false are left out of the payload. See references/overview.md.

Headers

Header When
Authorization Request authentication is on (or you set it yourself)
X-Downlink-Apikey, X-Downlink-Push, X-Downlink-Replace A Downlink API key is set. The key can schedule downlinks: don't log it
X-Tts-Domain The deployment's domain

Environment Variables

TTS_WEBHOOK_USERNAME=your-username   # the same values as in Request authentication
TTS_WEBHOOK_PASSWORD=your-password

Local Development

# Express / Next.js (use 8000 for FastAPI). No install or account required.
npx hookdeck-cli listen 3000 the-things-stack --path /webhooks/the-things-stack

Use the printed URL as the webhook's Base URL, turn on Request authentication with the same credentials, and enable Uplink message. See references/setup.md.

Reference Materials

  • [references/overview.md](referenc
Полный SKILL.md на GitHub

Установить the-things-stack-webhooks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/express/.env.exampleexamples/express/README.mdexamples/express/package.jsonexamples/express/src/index.jsexamples/fastapi/.env.exampleexamples/fastapi/README.mdexamples/fastapi/main.pyexamples/fastapi/requirements.txtexamples/fastapi/test_webhook.pyexamples/nextjs/.env.exampleexamples/nextjs/README.mdexamples/nextjs/app/webhooks/the-things-stack/route.tsexamples/nextjs/lib/verify-the-things-stack.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

Что делает скилл the-things-stack-webhooks?

Receive and authenticate The Things Stack webhooks (The Things Network and The Things Industries LoRaWAN Application Server). Use when creating a custom webhook in the Console, enabling Request authentication (Authorization: Basic header), checking basic auth credentials, choosing enabled event types and paths, handling the X-Downlink-Apikey header, or processing uplink_message, join_accept, downlink_ack, downlink_failed and location_solved messages.

Как установить скилл the-things-stack-webhooks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл the-things-stack-webhooks запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить the-things-stack-webhooks с