web-push-libs / web-push-php

Web Push library for PHP
MIT License
1.69k stars 295 forks source link

PHP Fatal error: Uncaught TypeError: Jose\Component\Core\Util\Ecc\PrivateKey::create(): #338 #352

Closed alpastar closed 6 months ago

alpastar commented 2 years ago

same error with #338

Setup

UBUNTU 20.04 LTS PHP-FPM 7.4.3 web-push-php Version: 7.0.0 Chrome-100

Features Used

code

use Minishlink\WebPush\WebPush; use Minishlink\WebPush\Subscription; require_once "vendor/autoload.php";

$sub = Subscription::create( [ "endpoint" => 'https://fcm.googleapis.com/fcm/send/fAPQ61 ------- uf', "keys" => [ 'p256dh'=>'BD --------------------- Tw' , 'auth' => 'f --------- w' ] , ]) ;

$payload = '{"msg":"Hello World!"}' ;

$webPush = new WebPush(); $report = $webPush->sendOneNotification($sub , $payload);

result -error

2022/04/13 22:39:46 [error] 368579#368579: *717 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to Jose\Component\Core\Util\Ecc\PrivateKey::create() must be an instance of Brick\Math\BigInteger, instance of GMP given, called in /var/www/public/push/vendor/minishlink/web-push/src/Encryption.php on line 355 and defined in /var/www/public/push/vendor/web-token/jwt-util-ecc/PrivateKey.php:57

Stack trace:

0 /var/www/public/push/vendor/minishlink/web-push/src/Encryption.php(355): Jose\Component\Core\Util\Ecc\PrivateKey::create()

1 /var/www/public/push/vendor/minishlink/web-push/src/Encryption.php(105): Minishlink\WebPush\Encryption::calculateAgreementKey()

2 /var/www/public/push/vendor/minishlink/web-push/src/Encryption.php(61): Minishlink\WebPush\Encryption::deterministicEncrypt()

3 /var/www/public/push/vendor/minishlink/web-push/src/WebPush.php(224): Minishlink\WebPush\Encryption::encrypt()

4 /var/www/public/push/vendor/minishlink/web-push/src/WebPush.php(171): Minishlink\WebPush\WebPush->prepare()

Oxmoze commented 2 years ago

If you expect answer here... this library seems abandoned. It is not working at all... I find this one: https://github.com/spomky-labs/web-push better design, better documentation and work as expected with chrome, edge and firefox. And a demo to test it: https://quiet-caverns-28842.herokuapp.com/

Dead simple