Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base64 backward compatibility and performance #400

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

sleptor
Copy link
Contributor

@sleptor sleptor commented May 15, 2024

Related to #397

After replacing the spooky-labs/base64url library with another one, you lost backward compatibility since the new library can't decode standard base64 (non-URL safe). Also, the new library is much slower since it uses a pure PHP implementation of the base64 decoding algorithm.

This PR contains tests only, which are now falling on the master branch.

I would to borrow code here (from the old library) https://github.com/Spomky-Labs/base64url/blob/v2.x/src/Base64Url.php
and place it directly in the package, and refactor the code, of course.

The ideal solution would be to extract Base64 encoder as a dependency while adding the possibility of passing a custom encoder as a parameter.

Pseudo-code:

$myEncoder = new StandardBase64OnlyEncoder()
$wp = new WebPush();
$wp->setBase64Encoder($myEncoder);

However, it will require deep refractory; for example, the Encryption class must not be static anymore.

@Minishlink
Copy link
Member

Thanks! I reverted the problematic PR and will merge this in case there is enough arguments to switch over to paragonie (or adding this base64 encode/decode interface)

@Minishlink Minishlink merged commit 9d36211 into web-push-libs:master Jun 18, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants