Skip to content

Commit

Permalink
Fix timestamp format in signature verification
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostzero committed Feb 5, 2021
1 parent 42f7984 commit 17585a0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Objects/EventSubSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace romanzipp\Twitch\Objects;

use Carbon\Carbon;
use romanzipp\Twitch\Exceptions\SignatureVerificationException;
use Symfony\Component\HttpFoundation\HeaderBag;

Expand All @@ -23,6 +24,7 @@ class EventSubSignature
public static function verifyHeader(string $payload, HeaderBag $headers, string $secret, int $tolerance = 60): void
{
$timestamp = $headers->get('twitch-eventsub-message-timestamp');
$timestamp = Carbon::createFromFormat('Y-m-d\TH:i:s.u\Z', $timestamp, 'UTC');

if ( ! is_numeric($timestamp)) {
throw new SignatureVerificationException('Unable to extract timestamp and signatures from header');
Expand Down

0 comments on commit 17585a0

Please sign in to comment.