twitchdev / twitch-cli

The official Twitch CLI to make developing on Twitch easier.
Apache License 2.0
604 stars 71 forks source link

EventSub WebSocket eventsub subscription endpoint doesn't send correct response payload #226

Closed Xemdo closed 1 year ago

Xemdo commented 1 year ago

Brought to attention by @Awakened-Redstone

What is the problem?

When using EventSub WebSocket simulation, the endpoint localhost:8080/eventsub/subscriptions is available to emulate api.twitch.tv/helix/eventsub/subscriptions

The mock endpoint is returning the following data:

{
  "body": {
    "id": "3a5914c9-2dba-ebe8-b2c4-8ae90a04c114",
    "status": "enabled",
    "type": "channel.update",
    "version": "1",
    "created_at": "2023-04-11T18:12:24.4053977Z",
    "cost": 0,
    "condition": {

    },
    "transport": {
      "method": "websocket",
      "session_id": "39489cd5_9f9d8253",
      "connected_at": "2023-04-11T18:12:21.7012872Z"
    }
  },
  "total": 0,
  "max_total_cost": 10,
  "total_cost": 0
}

But the production endpoint is returning the following:

{
  "data": [
    {
      "id": "dd634805-672c-4673-accd-18eb1d5b1d03",
      "status": "enabled",
      "type": "channel.update",
      "version": "1",
      "condition": {
        "broadcaster_user_id": "57047445"
      },
      "created_at": "2023-04-11T18:08:28.936786622Z",
      "transport": {
        "method": "websocket",
        "session_id": "<removed>",
        "connected_at": "2023-04-11T18:08:24Z"
      },
      "cost": 0
    }
  ],
  "total": 1,
  "max_total_cost": 10,
  "total_cost": 0
}

Operating System

All

Architecture Version (x86, x64, arm, etc)

All

Steps to reproduce

  1. twitch event websocket start-server
  2. curl -kvl -X POST http://localhost:8080/eventsub/subscriptions -H "Client-ID: 4ofh8m0706jqpholgk00u3xvb4spct" -d '{"type":"channel.update","version":"1","condition":{"broadcaster_user_id": ""},"transport":{"method": "websocket","session_id": ""}}'
  3. curl -kvl -X POST http://api.twitch.tv/helix/eventsub/subscriptions -H "Client-ID: 4ofh8m0706jqpholgk00u3xvb4spct" -d '{"type":"channel.update","version":"1","condition":{"broadcaster_user_id": ""},"transport":{"method": "websocket","session_id": ""}}'
  4. Compare

Can use https://xemdo.github.io/twitch-websocket-tester/ to compare with DevTools instead of curl

Relevant log output

No response