fix: add guzzel dependency
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -9,16 +9,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace KTXM\ProviderJmapc\Service\Remote;
|
||||
|
||||
use GuzzleHttp\Client as HttpClient;
|
||||
use GuzzleHttp\Psr7\HttpFactory;
|
||||
use JmapClient\Authentication\Basic;
|
||||
use JmapClient\Authentication\Bearer;
|
||||
use JmapClient\Authentication\JsonBasic;
|
||||
use JmapClient\Authentication\JsonBasicCookie;
|
||||
use JmapClient\Client as JmapClient;
|
||||
use KTXC\Server;
|
||||
use KTXF\Resource\Provider\ResourceServiceBaseInterface;
|
||||
use KTXF\Resource\Provider\ResourceServiceIdentityBasic;
|
||||
use KTXF\Resource\Provider\ResourceServiceIdentityBearer;
|
||||
use KTXF\Resource\Provider\ResourceServiceIdentityOAuth;
|
||||
use KTXF\Resource\Provider\ResourceServiceLocationUri;
|
||||
use KTXM\ProviderJmapc\Providers\Mail\Service as MailService;
|
||||
use KTXM\ProviderJmapc\Providers\Contacts\Service as ContactsService;
|
||||
@@ -40,9 +36,6 @@ class RemoteService {
|
||||
*/
|
||||
public static function freshClient(MailService|FilesService $service): JmapClient {
|
||||
|
||||
// defaults
|
||||
$client = new JmapClient();
|
||||
$client->setTransportAgent(self::$clientTransportAgent);
|
||||
$location = $service->getLocation();
|
||||
$identity = $service->getIdentity();
|
||||
|
||||
@@ -50,12 +43,23 @@ class RemoteService {
|
||||
if ($location instanceof ResourceServiceLocationUri === false) {
|
||||
throw new \InvalidArgumentException('Service location is not a valid URI');
|
||||
}
|
||||
|
||||
// The JMAP client accepts transport abstractions only. Guzzle supplies the
|
||||
// PSR-18 client, while HttpFactory supplies both required PSR-17 factories.
|
||||
$httpFactory = new HttpFactory();
|
||||
$client = new JmapClient(
|
||||
transportClient: new HttpClient([
|
||||
'verify' => $location->getVerifyPeer(),
|
||||
]),
|
||||
requestFactory: $httpFactory,
|
||||
streamFactory: $httpFactory,
|
||||
);
|
||||
$client->setTransportAgent(self::$clientTransportAgent);
|
||||
$client->configureTransportMode($location->getScheme());
|
||||
$client->setHost($location->getHost() . ':' . $location->getPort());
|
||||
if (!empty($location->getPath())) {
|
||||
$client->setDiscoveryPath($location->getPath());
|
||||
}
|
||||
$client->configureTransportVerification((bool)$location->getVerifyPeer());
|
||||
// authentication
|
||||
if (($identity instanceof ResourceServiceIdentityBasic) === false) {
|
||||
throw new \InvalidArgumentException('Service identity is not a valid Basic or Bearer authentication');
|
||||
|
||||
Reference in New Issue
Block a user