From 1df10106a17ffbf92792a8aba6bca0f2e2902f1e Mon Sep 17 00:00:00 2001 From: Antonio Buedo Date: Wed, 25 Mar 2020 17:45:04 +0100 Subject: [PATCH] #v3.5.2003.0-rc - Security update (#39) * - Http headers fix --- src/BitPaySDK/Client.php | 4 ++-- src/BitPaySDK/Env.php | 2 +- src/BitPaySDK/Util/RESTcli/RESTcli.php | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/BitPaySDK/Client.php b/src/BitPaySDK/Client.php index 6ba65c45..7cb3a2d8 100644 --- a/src/BitPaySDK/Client.php +++ b/src/BitPaySDK/Client.php @@ -44,9 +44,9 @@ * Class Client * @package Bitpay * @author Antonio Buedo - * @version 3.5.2002.1 + * @version 3.5.2003 * See bitpay.com/api for more information. - * date 26.02.2020 + * date 25.03.2020 */ class Client { diff --git a/src/BitPaySDK/Env.php b/src/BitPaySDK/Env.php index f0b41183..0c328bd4 100644 --- a/src/BitPaySDK/Env.php +++ b/src/BitPaySDK/Env.php @@ -11,7 +11,7 @@ interface Env const TestUrl = "https://test.bitpay.com/"; const ProdUrl = "https://bitpay.com/"; const BitpayApiVersion = "2.0.0"; - const BitpayPluginInfo = "BitPay_PHP_Client_v3.5.2002.1"; + const BitpayPluginInfo = "BitPay_PHP_Client_v3.5.2003"; const BitpayApiFrame = "custom"; const BitpayApiFrameVersion = "1.0.0"; } \ No newline at end of file diff --git a/src/BitPaySDK/Util/RESTcli/RESTcli.php b/src/BitPaySDK/Util/RESTcli/RESTcli.php index 681d0da3..2938c444 100644 --- a/src/BitPaySDK/Util/RESTcli/RESTcli.php +++ b/src/BitPaySDK/Util/RESTcli/RESTcli.php @@ -47,8 +47,8 @@ public function init() 'base_url' => $this->_baseUrl, 'defaults' => [ 'headers' => [ - "x-accept-version" => Env::BitpayApiVersion, - 'X-BitPay-Plugin-Info' => Env::BitpayPluginInfo, + 'x-accept-version' => Env::BitpayApiVersion, + 'x-bitpay-plugin-info' => Env::BitpayPluginInfo, 'x-bitpay-api-frame' => Env::BitpayApiFrame, 'x-bitpay-api-frame-version' => Env::BitpayApiFrameVersion, ], @@ -65,6 +65,10 @@ public function post($uri, array $formData = [], $signatureRequired = true): str $fullURL = $this->_baseUrl.$uri; $headers = [ 'Content-Type' => 'application/json', + 'x-accept-version' => Env::BitpayApiVersion, + 'x-bitpay-plugin-info' => Env::BitpayPluginInfo, + 'x-bitpay-api-frame' => Env::BitpayApiFrame, + 'x-bitpay-api-frame-version' => Env::BitpayApiFrameVersion, ]; if ($signatureRequired) { @@ -96,6 +100,10 @@ public function get($uri, array $parameters = null, $signatureRequired = true): $fullURL = $this->_baseUrl.$uri; $headers = [ 'Content-Type' => 'application/json', + 'x-accept-version' => Env::BitpayApiVersion, + 'x-bitpay-plugin-info' => Env::BitpayPluginInfo, + 'x-bitpay-api-frame' => Env::BitpayApiFrame, + 'x-bitpay-api-frame-version' => Env::BitpayApiFrameVersion, ]; if ($parameters) { @@ -134,6 +142,10 @@ public function delete($uri, array $parameters = null): string } $headers = [ + 'x-accept-version' => Env::BitpayApiVersion, + 'x-bitpay-plugin-info' => Env::BitpayPluginInfo, + 'x-bitpay-api-frame' => Env::BitpayApiFrame, + 'x-bitpay-api-frame-version' => Env::BitpayApiFrameVersion, 'Content-Type' => 'application/json', 'x-signature' => $this->_ecKey->sign($fullURL), 'x-identity' => $this->_identity, @@ -162,6 +174,10 @@ public function update($uri, array $formData = []): string try { $fullURL = $this->_baseUrl.$uri; $headers = [ + 'x-accept-version' => Env::BitpayApiVersion, + 'x-bitpay-plugin-info' => Env::BitpayPluginInfo, + 'x-bitpay-api-frame' => Env::BitpayApiFrame, + 'x-bitpay-api-frame-version' => Env::BitpayApiFrameVersion, 'Content-Type' => 'application/json', 'x-signature' => $this->_ecKey->sign($fullURL.json_encode($formData)), 'x-identity' => $this->_identity,