Skip to content

Commit

Permalink
Apply fixes from StyleCI (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
freyo committed Jan 10, 2020
1 parent f00679d commit 60c7d59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/Plugins/TCaptchaV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public function handle($aid, $appSecretKey)
public function verify($ticket, $randStr, $userIP, array $options = [])
{
$params = array_merge([
'CaptchaType' => 9,
'Ticket' => $ticket,
'UserIp' => $userIP,
'Randstr' => $randStr,
'CaptchaType' => 9,
'Ticket' => $ticket,
'UserIp' => $userIP,
'Randstr' => $randStr,
'CaptchaAppId' => $this->aid,
'AppSecretKey' => $this->appSecretKey,
], $options);
Expand Down
35 changes: 18 additions & 17 deletions src/Plugins/Traits/TencentCloudAuthV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ protected function getCredentials()
}

/**
* @param array $args
* @param string $action
* @param string $service
* @param string $version
* @param array $args
* @param string $action
* @param string $service
* @param string $version
* @param string|int|null $timestamp
*
* @return bool|array
Expand All @@ -38,12 +38,12 @@ protected function request(array $args, $action, $service, $version, $timestamp
$args, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
),
'headers' => [
'X-TC-Action' => $action,
'X-TC-Region' => $this->getConfig()->get('region'),
'X-TC-Action' => $action,
'X-TC-Region' => $this->getConfig()->get('region'),
'X-TC-Timestamp' => $timestamp = $timestamp ?: time(),
'X-TC-Version' => $version,
'Authorization' => $this->getAuthorization($timestamp, $service, $body),
'Content-Type' => 'application/json',
'X-TC-Version' => $version,
'Authorization' => $this->getAuthorization($timestamp, $service, $body),
'Content-Type' => 'application/json',
],
]);

Expand Down Expand Up @@ -82,8 +82,8 @@ protected function normalize($contents)

/**
* @param string|int|null $timestamp
* @param string $service
* @param string $body
* @param string $service
* @param string $body
*
* @return string
*/
Expand All @@ -93,7 +93,7 @@ protected function getAuthorization($timestamp, $service, $body)
'%s Credential=%s/%s, SignedHeaders=%s, Signature=%s',
'TC3-HMAC-SHA256',
$this->getCredentials()['secretId'],
date('Y-m-d', $timestamp) . "/{$service}/tc3_request",
date('Y-m-d', $timestamp)."/{$service}/tc3_request",
'content-type;host',
hash_hmac(
'SHA256',
Expand All @@ -105,7 +105,7 @@ protected function getAuthorization($timestamp, $service, $body)

/**
* @param string|int|null $timestamp
* @param string $service
* @param string $service
*
* @return string
*/
Expand All @@ -114,10 +114,11 @@ protected function getRequestKey($timestamp, $service)
$secretDate = hash_hmac(
'SHA256',
date('Y-m-d', $timestamp),
'TC3' . $this->getCredentials()['secretKey'],
'TC3'.$this->getCredentials()['secretKey'],
true
);
$secretService = hash_hmac('SHA256', $service, $secretDate, true);

return hash_hmac('SHA256', 'tc3_request', $secretService, true);
}

Expand All @@ -143,8 +144,8 @@ protected function getCanonicalRequest($service, $body)

/**
* @param string|int|null $timestamp
* @param string $service
* @param string $body
* @param string $service
* @param string $body
*
* @return string
*/
Expand All @@ -153,7 +154,7 @@ protected function getSignatureString($timestamp, $service, $body)
return implode("\n", [
'TC3-HMAC-SHA256',
$timestamp,
date('Y-m-d', $timestamp) . "/{$service}/tc3_request",
date('Y-m-d', $timestamp)."/{$service}/tc3_request",
hash('SHA256', $this->getCanonicalRequest($service, $body)),
]);
}
Expand Down

0 comments on commit 60c7d59

Please sign in to comment.