Skip to content

Commit

Permalink
#v3.5.2003.0-rc - Security update (#39)
Browse files Browse the repository at this point in the history
* - Http headers fix
  • Loading branch information
Antonio Buedo authored Mar 25, 2020
1 parent aedf005 commit 1df1010
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/BitPaySDK/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/BitPaySDK/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
20 changes: 18 additions & 2 deletions src/BitPaySDK/Util/RESTcli/RESTcli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1df1010

Please sign in to comment.