| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 25 | protected function isValid(string $signature, $request): bool |
||
| 26 | { |
||
| 27 | $payload = $request->getContent(); |
||
|
|
|||
| 28 | $secret = config('multicoin.api_key'); |
||
| 29 | if (empty($secret)) { |
||
| 30 | throw WebhookFailed::signingSecretNotSet(); |
||
| 31 | } |
||
| 32 | $timestamp = $request->header('timestamp'); |
||
| 33 | $token = $request->header('token'); |
||
| 34 | $computedSignature = hash_hmac('sha256', $token.$timestamp, $secret); |
||
| 35 | |||
| 36 | return hash_equals($signature, $computedSignature); |
||
| 37 | } |
||
| 39 |