Skip to content

Commit 23b0675

Browse files
committed
Add verification key setter
1 parent 6d3a368 commit 23b0675

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/WebhookParser.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ public function __construct(string $verificationKey)
2626
$this->_verificationKey = $verificationKey;
2727
}
2828

29-
public function verifyHeaders(array $headers): bool
29+
/**
30+
* @param string $verificationKey
31+
*
32+
* @return WebhookParser
33+
*/
34+
public function setVerificationKey(string $verificationKey)
35+
{
36+
$this->_verificationKey = $verificationKey;
37+
return $this;
38+
}
39+
40+
public function verifyHeaders(array $headers, $verifyKey = null): bool
3041
{
3142
//Payload Checksum
3243
$checksum = isset($headers['x-fident-checksum']) ? $headers['x-fident-checksum'] : '';
@@ -35,7 +46,7 @@ public function verifyHeaders(array $headers): bool
3546
$verification = isset($headers['x-fident-verification']) ? $headers['x-fident-verification'] : '';
3647

3748
//Verify the checksum + verification key matches the verification has
38-
return sha1($checksum . $this->_verificationKey) === $verification;
49+
return sha1($checksum . ($verifyKey ?? $this->_verificationKey)) === $verification;
3950
}
4051

4152
public function verifyWebhook(array $headers): bool

0 commit comments

Comments
 (0)