Closed Bug 1497430 Opened 7 years ago Closed 11 months ago

Implement `PushManager::supportedContentEncodings`

Categories

(Core :: DOM: Push Subscriptions, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: lina, Assigned: saschanaz)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(2 files)

http://w3c.github.io/push-api/#pushmanager-interface, https://github.com/w3c/push-api/pull/252 I think this was tricky when I first looked at it because `PushManager` is a JS-implemented WebIDL, and I ran into issues trying to expose a static array on the binding. But that was also a year and a half ago. :-) We don't support `FrozenArray` yet, either; see bug 1236777. https://hg.mozilla.org/mozilla-central/rev/bc0196fd88e5 has a workaround we can use.
Priority: -- → P3
Severity: normal → S3

Apparently the lack of this is blocking migration to aes128gcm. (See also https://bugzilla.mozilla.org/show_bug.cgi?id=1925631#c41)

Assignee: nobody → krosylight

Removing dependency on bug 1236777, we have an established workaround.

No longer depends on: 1236777
See Also: → 1363870
Attachment #9433514 - Attachment description: WIP: Bug 1497430 - Implement PushManager.supportedContentEncodings → Bug 1497430 - Implement PushManager.supportedContentEncodings r=#webidl
Pushed by krosylight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cf836d486e02 Implement PushManager.supportedContentEncodings r=webidl,asuth
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/48847 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot

FF134 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/36922

My understanding is that

  1. this is also shipped (not just implemented)
  2. The preference dom.push.indicate_aesgcm_support.enabled isn't relevant to external developers
  3. The underlying implementation is not as in the spec but this is invisible to developers - (i.e. not using FrozenArray but the values in the returned array are unmodifiable).
  4. This work in web workers too?
  5. What does the web application do with the information? (I don't understand the push API). It sounds like the push notifications come to a service worker encrypted with this algorithm using the key provided by the application in the subscription. IF that is correct, does the app have to do anything - i.e. does it have to decrypt the message or does that get done on its behalf somehow?

Is that all correct?

Flags: needinfo?(krosylight)

(In reply to Hamish Willee from comment #12)

FF134 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/36922

My understanding is that

  1. this is also shipped (not just implemented)
  2. The preference dom.push.indicate_aesgcm_support.enabled isn't relevant to external developers
  3. The underlying implementation is not as in the spec but this is invisible to developers - (i.e. not using FrozenArray but the values in the returned array are unmodifiable).
  4. This work in web workers too?

All yes.

  1. What does the web application do with the information? (I don't understand the push API). It sounds like the push notifications come to a service worker encrypted with this algorithm using the key provided by the application in the subscription. IF that is correct, does the app have to do anything - i.e. does it have to decrypt the message or does that get done on its behalf somehow?

Is that all correct?

The app sends the info to the app server - and then the server decides which content encoding to encrypt push payload. Decryption happens in the browser side, not app side.

Flags: needinfo?(krosylight)

Thank you

What does the web application do with the information? (I don't understand the push API).

The app sends the info to the app server - and then the server decides which content encoding to encrypt push payload.

  1. How?

TLDR: I "think" the answer is that it is up to the app to define its own protocol for sharing the encoding supported by the browser - the mechanism doesn't appear to be in the spec, it isn't in the subscription object (which you are supposed to send to the app server), so I don't see any other way the app server can get it.

The app server adds the info to each push request in each request to the push server as the Content-Encoding.

My guess is that the information is often hard coded, and not sent at all.

  1. Decryption happens in the browser side, not app side.

So the app doesn't need this information except to send it ("somehow") to the application server. Right?


This is FYI only - my thinking that fed the TLDR above.

Flags: needinfo?(krosylight)

(In reply to Hamish Willee from comment #14)

Thank you

What does the web application do with the information? (I don't understand the push API).

The app sends the info to the app server - and then the server decides which content encoding to encrypt push payload.

  1. How?

Via whatever way depending on the app server implementation. The only standard part here is that the server gets the content encoding support info, use the proper library to encrypt based on the support data (that follows RFC 8291), and then send it to the push endpoint URL (which is PushSubscription.endpoint, also being sent to the app server by whatever app server dependent way)

Think of something like:

// given `subscription` being PushSubscription:
fetch(`https://example.com/push/`, {
  method: "post",
  body: JSON.stringify({
    endpoint: subscription.endpoint,
    p256dh: subscription.getKey("p256dh"),
    auth: subscription.getKey("auth"),
    encoding: PushManager.supportedContentEncodings,
    /* ... some user data so that the server would know which user this is for */
  });
});

And then example.com will encrypt its push notification payload with the provided keys and support data and send it to the endpoint (and of course not immediately but when there's a need to push a notification to clients)

  1. Decryption happens in the browser side, not app side.

So the app doesn't need this information except to send it ("somehow") to the application server. Right?

Yes.

Flags: needinfo?(krosylight)

Thank you! Really helpful - none of that was captured in our docs and now is.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: