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

fix: [BREAKING] remove legacy subscription; change subscription interface #394

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Rotzbua
Copy link
Contributor

@Rotzbua Rotzbua commented Feb 6, 2024

Changes

Breaking:

  • change default encoding to aes128g
  • change subscription interface
  • Remove legacy GCM
  • Remove old Chrome subscription support

Feature:

  • convert contentEncoding to typesafe enum

Reference

fixes #381
fixes #345
reference #388

@Minishlink
Copy link
Member

Hey sorry I plan to review this this weekend, thanks!

Copy link
Member

@Minishlink Minishlink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sorry for the delay, I'm not sure about the change about null => "" though

$associativeArray['publicKey'] ?? null,
$associativeArray['authToken'] ?? null,
$associativeArray['contentEncoding'] ?? "aesgcm"
$associativeArray['endpoint'] ?? "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint shouldn't be empty, it should throw before, shouldn't it?

$associativeArray['authToken'] ?? null,
$associativeArray['contentEncoding'] ?? "aesgcm"
$associativeArray['endpoint'] ?? "",
$associativeArray['keys']['p256dh'] ?? "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is an improvement, having an empty string instead of null ?

* @author Sergii Bondarenko <sb@firstvector.org>
*/
interface SubscriptionInterface
{
public function getEndpoint(): string;

public function getPublicKey(): ?string;
public function getPublicKey(): string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A subscription can have no public key, auth token or content encoding (sent without any payload)

Remove legacy GCM
Remove old Chrome subscription support
[BREAKING] change default encoding to aes128gcm
@@ -212,25 +221,25 @@ private static function createContext(string $clientPublicKey, string $serverPub
*
* @throws \ErrorException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add @throws \ValueError here?

protected readonly string $endpoint,
protected readonly string $publicKey,
protected readonly string $authToken,
ContentEncoding|string $contentEncoding = ContentEncoding::aes128gcm,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous space?

if(is_string($contentEncoding)) {
try {
if(empty($contentEncoding)) {
$this->contentEncoding = ContentEncoding::aesgcm; // default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the default be aes128gcm?

@Gugu7264
Copy link
Contributor

Hopefully this can be finished & merged soon :)

@Gugu7264
Copy link
Contributor

@Minishlink Just wondering, what's currently missing in that PR?
The required fixes in reviews? (and conflicts)

@Minishlink
Copy link
Member

Yes that's right

@Minishlink
Copy link
Member

I might delay this to v10 and release v9 at the beginning of july. Let me know @Rotzbua if you have time in the near future for this PR, thank you

@cclegend90
Copy link

Hi,
I have over 25k subscribers and need to switch to the new FCM v1 API since the old version will be deprecated soon. When will this library support the v1 API? I'm using Perfecty Push, which depends on this library.

Thanks for the amazing repo!

@Minishlink
Copy link
Member

Hello, this library is agnostic about which endpoint is sent by the browser, it only requires compliance with the Web Push standard.
Regarding FCM deprecation, Google said that it will still support the old endpoints https://stackoverflow.com/a/77958717 (but anyway this is not a question for this repository but more for Google)

@Rotzbua Rotzbua marked this pull request as draft July 16, 2024 14:43
@Rotzbua
Copy link
Contributor Author

Rotzbua commented Jul 16, 2024

Converted to draft until I have time and back into the php topic.

@cclegend90
Copy link

Thanks for the update! I have one more question: what's the pull request about? Are you planning on supporting the v1 HTTP API too, or is it focused on something else? Looking forward to your response!

@Rotzbua
Copy link
Contributor Author

Rotzbua commented Jul 18, 2024

@cclegend90 It is just cleanup of obsolete code. The FCM v1 HTTP API (for native apps) is not the Push API (for browser) and not target of this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants