Command Palette

Search for a command to run...

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

papergames-webhooks

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

Receive and verify Papergames (papergames.io) webhooks, delivered by Svix. Use when setting up a Papergames webhook handler for the embeddable games API…

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

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

Papergames Webhooks

Papergames is an online multiplayer board-game platform (Battleship, Tic Tac Toe, Connect 4, Gomoku, Chess) with an embeddable games API. You create a game session over the REST API, embed its playUrl / watchUrl in an iframe, and Papergames sends a webhook as each game in the session starts and finishes. Webhooks are delivered by Svix and signed with the svix- header prefix. (Not to be confused with Paperform, the form builder.)

When to Use This Skill

  • How do I receive Papergames webhooks?
  • How do I verify a Papergames webhook signature (svix-signature)?
  • Where do I find my Papergames webhook secret (whsec_...)?
  • How do I handle game.started and game.finished events?
  • How do I find the winner of a Papergames game, or map players to my own user IDs?
  • Why is my Papergames webhook signature verification failing?

Verification (core)

Header Value
svix-id Unique message ID; the same on every retry, so it's your idempotency key
svix-timestamp Unix seconds
svix-signature Space-delimited v1,<base64> entries (more than one during secret rotation)

Signed content is {svix-id}.{svix-timestamp}.{raw body}, HMAC-SHA256, standard base64. The key is the base64-decoded part of the secret after whsec_:

const crypto = require('crypto');

// rawBody: exact request bytes (Buffer/string), NOT re-serialized JSON
function verifyPapergames(rawBody, headers, secret = process.env.PAPERGAMES_WEBHOOK_SECRET) {
  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  if (key.length === 0) throw new Error('Invalid PAPERGAMES_WEBHOOK_SECRET');
  const expected = Buffer.from(crypto.createHmac('sha256', key)
    .update(`${headers['svix-id']}.${headers['svix-timestamp']}.`).update(rawBody).digest('base64'));
  return headers['svix-signature'].split(' ').some((entry) => {
    const [version, sig] = entry.split(',', 2);
    if (version !== 'v1' || !sig) return false; // ignore unknown version tags
    const candidate = Buffer.from(sig);
    return candidate.length === expected.length && crypto.timingSafeEqual(candidate, expected);
  });
}

Also check svix-timestamp is a positive integer within your tolerance. Papergames publishes no number; the examples default to 5 minutes (the Svix libraries' default) and let you widen or disable it with PAPERGAMES_WEBHOOK_TOLERANCE_SECONDS, because a strict window can reject late retries or replays (see references/verification.md). The official svix library (npm and PyPI) is a supported alternative, with a fixed 5-minute window. Read the raw body: express.raw(), await request.text() in Next.js, await request.body() in FastAPI.

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

Payload Envelope

The body is Papergames' own envelope, not the Standard Webhooks type / data shape. Route on body.eventType; the game session is body.payload. There's no event-type header, so parse the body after verification:

{
  "eventType": "game.finished",
  "payload": {
    "createdAt": "2023-11-03T10:34:28.191Z",
    "gamesPlayed": 1,
    "players": [
      { "externalId": "PEP_001", "name": "Pepito", "score": 1 },
      { "externalId": "JD_001", "name": "John Doe", "score": 0 }
    ],
    "status": "playing",
    "uid": "8qgmUmqJj",
    "updatedAt": "2023-11-03T10:34:57.484Z"
  }
}
  • uid is the game session ID returned when you created the session; use it to find your record.
  • externalId is your user ID, present only if you passed externalUserId on the iframe URL. Fall back to uid + name.
  • There's no winner field: compare players[].score on game.finished.
  • status stays "playing" on game.finished (a session can hold several games), so don't use it to detect the end of a session.
  • The docs' prose names the root webhookPayload while the JSON examples have no wrapper. The examples follow the JSON and also accept the envelope nested under webhookPayload.

Common Event Types

Event (eventType) Fired when
game.started A game within a game session starts (can fire several times per session)
game.finished A game within a game session finishes (can fire several times per session)

These are the only two documented events. Each endpoint subscribes to the events it chooses, and the list may grow, so acknowledge unknown types with 2xx. After all retries fail, Svix sends a message.attempt.exhausted operational webhook. Papergames doesn't document its payload or which endpoint receives it. See references/overview.md.

Delivery Semantics

Return 2xx quickly and process asynchronously. Failed attempts are retried immediately

Полный SKILL.md на GitHub

Установить papergames-webhooks в Claude Code и Claude Desktop

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

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

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

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

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

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

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

TODO.mdexamples/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/papergames/route.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

Что делает скилл papergames-webhooks?

Receive and verify Papergames (papergames.io) webhooks, delivered by Svix. Use when setting up a Papergames webhook handler for the embeddable games API, debugging svix-id / svix-timestamp / svix-signature verification (HMAC-SHA256, base64, whsec_ secret), or handling game session events game.started and game.finished (eventType / payload envelope, scores, externalId).

Как установить скилл papergames-webhooks?

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

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

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

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

Сравнить papergames-webhooks с