google2fa-qrcode
google2fa-qrcode copied to clipboard
Chillerlan fixes
This PR contains a couple of fixes:
- The Chillerlan adapter implementation currently produces a broken SVG QR code as the underlying Chillerlan implementation already does the base64 encode by default and the Chillerlan adapter in this package base64 encodes an already base64 encoded output. There is a test which asserts the expected output but it's failing (and now it passes again with this fix). It looks like the Travis CI pipeline is not running at all, otherwise this would've been caught a lot sooner as it never worker properly.
- Without this fix I thought I could override the
imageBase64option of the underlying Chillerlan implementation so that it doesn't do the base64 encode as this package already does it, but the\PragmaRX\Google2FAQRCode\QRCode\Chillerlan::setOptionsmethod is for some reason protected which makes it unusable. I've chaged the visibility topublic.
In the meantime I've worked around this in my Laravel project by using an anonymous class which overrides the $options array.
$this->app->bind(Google2FA::class, function (): Google2FA {
$chillerlan = new class() extends Chillerlan {
protected $options = ['imageBase64' => false];
};
return new Google2FA($chillerlan);
});
- I've fixed some docblock issues, the Chillerlan
class_existscheck which also checks for theBaconQrCode\Renderer\ImageRendererclass existence which doesn't make sense and I've updated the README.md (the PHP requirement is fixed).
Hi, just a heads-up: base64 output for SVG exists only from v3.4 onwards (v4.x backport), so the best bet in this case is to always disable base64 and let Google2FA handle it - like the workaround above does.