Skip to content

fix: use device auth for web push deregistration#2000

Merged
owenpearson merged 2 commits intomainfrom
push-deregister-device-auth
Apr 15, 2025
Merged

fix: use device auth for web push deregistration#2000
owenpearson merged 2 commits intomainfrom
push-deregister-device-auth

Conversation

@owenpearson
Copy link
Copy Markdown
Member

@owenpearson owenpearson commented Apr 15, 2025

resolves #1999

Summary by CodeRabbit

  • New Features

    • The push notification deactivation method can now be used without specifying a callback, providing more flexibility for users.
  • Bug Fixes

    • Improved authentication handling during push notification deregistration for enhanced reliability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2025

Walkthrough

The changes update the Push interface by making the deregisterCallback parameter in the deactivate method optional, allowing the method to be called with or without a callback. Additionally, the deregister method in the ActivationStateMachine class now retrieves authentication details using the local device's getAuthDetails method, instead of constructing headers and parameters directly. This improves how authentication is handled during push deregistration, particularly affecting web push deactivation flows.

Changes

File(s) Change Summary
ably.d.ts Made deregisterCallback parameter in Push.deactivate method optional in the type declaration.
src/plugins/push/pushactivation.ts Modified ActivationStateMachine.deregister to use device.getAuthDetails for authentication.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Device
    participant ActivationStateMachine
    participant RESTResource

    Client->>ActivationStateMachine: deregister()
    ActivationStateMachine->>Device: getAuthDetails(client, headers, params)
    Device-->>ActivationStateMachine: authDetails (headers, params)
    ActivationStateMachine->>RESTResource: delete(url, authDetails.headers, authDetails.params)
    RESTResource-->>ActivationStateMachine: response
    ActivationStateMachine-->>Client: handle result
Loading

Assessment against linked issues

Objective Addressed Explanation
Allow browser deactivation without requiring push-admin capability (#1999)

Poem

A hop and a skip, with code made neat,
Now push deactivates—no admin feat!
Auth flows through the device, so light,
Deregister works, both day and night.
Optional callbacks, a gentle touch,
This bunny approves the changes—so much!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 257c4e6 and dc59ccb.

📒 Files selected for processing (2)
  • ably.d.ts (1 hunks)
  • src/plugins/push/pushactivation.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
ably.d.ts (1)
src/plugins/push/pushactivation.ts (1)
  • DeregisterCallback (23-23)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: test-browser (webkit)
  • GitHub Check: test-node (20.x)
  • GitHub Check: test-node (18.x)
  • GitHub Check: test-browser (firefox)
  • GitHub Check: test-node (16.x)
  • GitHub Check: test-browser (chromium)
🔇 Additional comments (2)
ably.d.ts (1)

2644-2644: Good change: Makes deregisterCallback parameter optional

This change enhances flexibility in the Push interface by making the deregisterCallback parameter optional. This allows clients to call the deactivate method without providing a custom deregistration callback, falling back to the default implementation.

src/plugins/push/pushactivation.ts (1)

269-279: Improved authentication handling for push deregistration

Now using the device's getAuthDetails method to retrieve the proper authentication details rather than directly using the local headers and params. This change properly aligns with the updated deactivate method signature in the interface and ensures more robust authentication during push deregistration.

The modification correctly retrieves up-to-date authentication details from the device context, which is especially important for web push deactivation flows where authentication details might change between registration and deregistration.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator

@ttypic ttypic left a comment

Choose a reason for hiding this comment

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

LGTM

@owenpearson owenpearson merged commit ac6e906 into main Apr 15, 2025
8 of 14 checks passed
@owenpearson owenpearson deleted the push-deregister-device-auth branch April 15, 2025 12:54
VeskeR added a commit that referenced this pull request Apr 16, 2025
VeskeR added a commit that referenced this pull request Apr 16, 2025
This commit merges changes from the next PRs:
- #2001
- #2002
- #2000
- #1953
- #1989
- #1988
- #1984
- #1949
- #1980
- #1979
- #1978
- #1976
- #1962
- #1959
- #1955
- #1957
- #1940
- #1925
- #1947
- #1946
- #1945
- #1944

into the integration/liveobjects branch. No significant changes made
during merge conflict resolution.
VeskeR added a commit that referenced this pull request Apr 16, 2025
This commit merges changes from the next PRs:
- #2001
- #2002
- #2000
- #1953
- #1989
- #1988
- #1984
- #1949
- #1980
- #1979
- #1978
- #1976
- #1962
- #1959
- #1955
- #1957
- #1940
- #1925
- #1947
- #1946
- #1945
- #1944

into the integration/liveobjects branch. No significant changes made
during merge conflict resolution.
VeskeR added a commit that referenced this pull request Apr 16, 2025
This commit merges changes from the next PRs:
- #2001
- #2002
- #2000
- #1953
- #1989
- #1988
- #1984
- #1949
- #1980
- #1979
- #1978
- #1976
- #1962
- #1959
- #1955
- #1957
- #1940
- #1925
- #1947
- #1946
- #1945
- #1944

into the integration/liveobjects branch. No significant changes made
during merge conflict resolution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Web Push, browser deactivation not possible without push-admin capability

2 participants