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

Web Push Payload Encryption #229

Open
shahryarjb opened this issue Oct 12, 2022 · 1 comment
Open

Web Push Payload Encryption #229

shahryarjb opened this issue Oct 12, 2022 · 1 comment

Comments

@shahryarjb
Copy link

shahryarjb commented Oct 12, 2022

Request for feature. 🌹

Hi, I created a post in elixir forum https://elixirforum.com/t/how-to-send-push-notification-with-pigeon-when-we-have-subscriptions/50934

So I asked about Web Push Payload Encryption

When we have a subscription like

{
  "endpoint": "https://fcm.googleapis.com/fcm/send/USER_STUFF",
  "keys": {
    "auth": "AUTH_CODE",
    "p256dh": "P256DH_CODE"
  }
}

which is created by this code in service worker (sw.js) file:

var vapidPublicKey = 'MY_PUBLIC_KEY';
var convertedVapidPublicKey = urlBase64ToUint8Array(vapidPublicKey);
return reg.pushManager.subscribe({
  userVisibleOnly: true,
  applicationServerKey: convertedVapidPublicKey,
});

I think your library does not support it, I could not be able to find any document. I work with https://www.npmjs.com/package/web-push in JavaScript and recently found a library https://github.com/danhper/elixir-web-push-encryption in elixir to support it.

If it is possible, support this Feature

Thank you in advance for all your efforts.

@petermm
Copy link

petermm commented Oct 28, 2022

the elixir library (https://github.com/danhper/elixir-web-push-encryption) works great - and present day webpush is a totally different from the classic app push services that pigeon support.

namely you do individual POST per browser push subscription:

    ...
    msg = %{
      title: "Chat: #{user.first_name} #{user.sur_name}",
      body: "#{message_text}",
      openUrl: "/chat?topic=#{message.room_id}"
    }

    browsers
    |> Enum.each(fn browser ->
      subscription = %{
        keys: %{
          p256dh: browser.p256dh,
          auth: browser.auth
        },
        endpoint: browser.endpoint
      }

      {:ok, response} = WebPushEncryption.send_web_push(Jason.encode!(msg), subscription)
      ...

which is totally different from what Pigeon does (maintain a http2 connection/stream to the push servers)..

so with all respect I see little reason for Pigeon to support webpush - especially as there already is a well functioning elixir 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
Development

No branches or pull requests

2 participants