for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace lepiaf\SapientBundle\GuzzleHttp\Middleware;
use ParagonIE\ConstantTime\Base64UrlSafe;
use ParagonIE\Sapient\CryptographyKeys\SigningSecretKey;
use ParagonIE\Sapient\Sapient;
use Psr\Http\Message\RequestInterface;
class SignRequestMiddleware
{
private $sapient;
private $privateKey;
public function __construct(Sapient $sapient, string $privateKey)
$this->sapient = $sapient;
$this->privateKey = $privateKey;
}
public function __invoke(callable $handler)
return function (RequestInterface $request, array $options) use ($handler) {
$request = $this->sapient->signRequest(
$request,
new SigningSecretKey(Base64UrlSafe::decode($this->privateKey))
);
return $handler($request, $options);
};