Please specify the versions (i.e. Chrome Beta, Firefox Beta etc).
Problem
Please explain what behaviour you are seeing.
Hi, I am using this package in production and most of the notifications to differents users seems to work. But today I got the following error:
`
[13-Aug-2023 08:52:55 Europe/Paris] PHP Warning: hex2bin(): Hexadecimal input string must have an even length in /home/XXX/public_html/vendor/minishlink/web-push/src/Utils.php on line 62
[13-Aug-2023 08:52:55 Europe/Paris] PHP Warning: hex2bin(): Hexadecimal input string must have an even length in /home/XXX/public_html/vendor/minishlink/web-push/src/Utils.php on line 63
[13-Aug-2023 08:52:55 Europe/Paris] PHP Fatal error: Uncaught TypeError: Base64Url\Base64Url::encode(): Argument #1 ($data) must be of type string, bool given, called in /home/XXX/public_html/vendor/minishlink/web-push/src/Encryption.php on line 99 and defined in /home/XXX/public_html/vendor/spomky-labs/base64url/src/Base64Url.php:33
Stack trace:
thrown in /home/XXX/public_html/vendor/spomky-labs/base64url/src/Base64Url.php on line 33`
It seems that there is a problem in the file Utils.php line 62 on this lines:
return [ hex2bin(mb_substr($data, 0, $dataLength / 2, '8bit')), hex2bin(mb_substr($data, $dataLength / 2, null, '8bit')), ];
Expected
Please explain what you expected to happen
The notification should be sent like the other ones that works.
Features Used
[x] VAPID Support
[x] Sending with Payload
Example / Reproduce Case
Please provide a code sample that reproduces the issue. If there is a
repository that reproduces the issue please put the link here.
I can not really provide a code to reproduces that since I think I should not share my private key but do not hesitate to tell me if you need unsensitive data.
Here is an example of the code that init the web push and send the notifications maybe I missed something ?
Please put any remaining notes here.
I don't really know why it is not working for an user but I was not able to test it for firefox since I am not really able to reproduce that.
NOTE: Please test in a least two browsers (i.e. Chrome and Firefox). This helps with diagnosing problems quicker.
Setup
Problem
Hi, I am using this package in production and most of the notifications to differents users seems to work. But today I got the following error:
` [13-Aug-2023 08:52:55 Europe/Paris] PHP Warning: hex2bin(): Hexadecimal input string must have an even length in /home/XXX/public_html/vendor/minishlink/web-push/src/Utils.php on line 62 [13-Aug-2023 08:52:55 Europe/Paris] PHP Warning: hex2bin(): Hexadecimal input string must have an even length in /home/XXX/public_html/vendor/minishlink/web-push/src/Utils.php on line 63 [13-Aug-2023 08:52:55 Europe/Paris] PHP Fatal error: Uncaught TypeError: Base64Url\Base64Url::encode(): Argument #1 ($data) must be of type string, bool given, called in /home/XXX/public_html/vendor/minishlink/web-push/src/Encryption.php on line 99 and defined in /home/XXX/public_html/vendor/spomky-labs/base64url/src/Base64Url.php:33 Stack trace:
0 /home/XXX/public_html/vendor/minishlink/web-push/src/Encryption.php(99): Base64Url\Base64Url::encode(false)
1 /home/XXX/public_html/vendor/minishlink/web-push/src/Encryption.php(61): Minishlink\WebPush\Encryption::deterministicEncrypt('{"title":"New p...', '\x04\x11<\x8D[a\xF6\xE1\xA1\xE7\x9B\xC2\xD1%3...', '\x01\xF8h*bA\xBCkox\xA0P\x8D,\xE6...', 'aes128gcm', Array, '-\xB4F\x8Ed\x05H\x96T\n\xC8\xFB\x00|\xCC...')
2 /home/XXX/public_html/vendor/minishlink/web-push/src/WebPush.php(217): Minishlink\WebPush\Encryption::encrypt('{"title":"New p...', 'BBE8jVth 9uGh55...', 'AfhoKmJBvGtveKB...', 'aes128gcm')
3 /home/XXX/public_html/vendor/minishlink/web-push/src/WebPush.php(164): Minishlink\WebPush\WebPush->prepare(Array)
4 /home/XXX/public_html/src/model/NotificationManager.php(176): Minishlink\WebPush\WebPush->flush()
5 /home/XXX/public_html/src/model/PrivateMessageManager.php(347): model\NotificationManager->sendNotification(15693, 'private_message', '/!\ XXXXXXXX pr...')
6 /home/XXX/public_html/src/controller/PrivateMessagesController.php(112): model\PrivateMessageManager->sendNewMessage('Hi,\n\nBy being p...', 51966, 1)
7 /home/XXX/public_html/private-messages.php(22): controller\PrivateMessagesController->sendNewMessage()
8 {main}
thrown in /home/XXX/public_html/vendor/spomky-labs/base64url/src/Base64Url.php on line 33`
It seems that there is a problem in the file Utils.php line 62 on this lines:
return [ hex2bin(mb_substr($data, 0, $dataLength / 2, '8bit')), hex2bin(mb_substr($data, $dataLength / 2, null, '8bit')), ];
Expected
The notification should be sent like the other ones that works.
Features Used
Example / Reproduce Case
I can not really provide a code to reproduces that since I think I should not share my private key but do not hesitate to tell me if you need unsensitive data.
Here is an example of the code that init the web push and send the notifications maybe I missed something ?
$auth = [ 'VAPID' => [ 'subject' => WEB_PUSH_DOMAIN, 'publicKey' => WEB_PUSH_NOTIFICATION_PUBLIC_KEY, 'privateKey' => WEB_PUSH_NOTIFICATION_PRIVATE_KEY, ], ]; try { $webPush = new WebPush($auth); foreach ($webPushTokens as $token) { $webPush->queueNotification( Subscription::create([ 'endpoint' => $token['endpoint'], 'contentEncoding' => $token['content_encoding'], 'keys' => [ 'p256dh' => $token['p256dh'], 'auth' => $token['token'] ] ]), json_encode([ 'title' => $title, 'body' => $text ]) ); } foreach ($webPush->flush() as $report) { } } catch (Exception) { }
Other