From 31b61a78f7d7475d9ba453b854aa5441af9977b6 Mon Sep 17 00:00:00 2001
From: Marcos Caceres
Date: Mon, 11 Dec 2023 11:00:49 +1100
Subject: [PATCH 1/2] Introduce 'push subscription owner' concept
---
index.html | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/index.html b/index.html
index 9fbeca9..3fd4de3 100644
--- a/index.html
+++ b/index.html
@@ -63,9 +63,9 @@
a push service. An application server can send a push message at any
time, even when a web application or user agent is inactive. The push service
ensures reliable and efficient delivery to the user agent. Push messages are
- delivered to a Service Worker that runs in the origin of the web application, which
- can use the information in the message to update local state or display a notification to
- the user.
+ delivered to a [=push subscription owner=] that runs in the origin of the web application,
+ which can use the information in the message to update local state or display a
+ notification to the user.
This specification is designed for use with the web push protocol, which describes
@@ -172,9 +172,16 @@
A push subscription is a message delivery context established between the
user agent and the push service on behalf of a web application. Each
- push subscription is associated with a service worker registration and a
+ push subscription is associated with a [=push subscription owner=].
+
+
+ A push subscription owner refers to a service worker registration. A
service worker registration has at most one push subscription.
+
+ Future updates to this specification could expand the definition of a [=push subscription
+ owner=] to include other types, broadening the range of possible implementations.
+
A push subscription has an associated push endpoint. It MUST be the
absolute URL exposed by the push service where the application server can
@@ -431,13 +438,13 @@
the push service delivers the message to a specific user agent,
identifying the push endpoint in the message;
- the user agent identifies the intended Service Worker and activates it as
- necessary, and delivers the push message to the Service Worker.
+ the user agent identifies the intended [=push subscription owner=] and activates
+ it as necessary, and delivers the push message to the [=push subscription owner=].
- This overall framework allows application servers to activate a Service
- Worker in response to events at the application server. Information about those
+ This overall framework allows application servers to activate a [=push subscription
+ owner=] in response to events at the application server. Information about those
events can be included in the push message, which allows the web application to
react appropriately to those events, potentially without needing to initiate network
requests.
From 95aeb98872672eae3492d96c4bc3a3f382bbae95 Mon Sep 17 00:00:00 2001
From: Marcos Caceres
Date: Thu, 14 Dec 2023 15:46:32 +1100
Subject: [PATCH 2/2] Expose pushManager on Navigator
---
index.html | 130 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 86 insertions(+), 44 deletions(-)
diff --git a/index.html b/index.html
index 3fd4de3..0d328d2 100644
--- a/index.html
+++ b/index.html
@@ -175,12 +175,29 @@
push subscription is associated with a [=push subscription owner=].
- A push subscription owner refers to a service worker registration. A
- service worker registration has at most one push subscription.
+ A push subscription owner can be one of the following:
+
+ -
+ [=Service worker registration=]
+
+ -
+ A [=service worker registration=] has at most one [=push subscription=] associated with
+ it.
+
+ -
+ [=Environment settings object=]
+
+ -
+ This represents the security origin for the [=push subscription=]. An [=environment
+ settings object=] has at most one [=push subscription=] associated with it.
+
+
- Future updates to this specification could expand the definition of a [=push subscription
- owner=] to include other types, broadening the range of possible implementations.
+ This specification currently details handling of push subscriptions in the context of
+ both [=service worker registrations=] and an [=environment settings object=]. Future
+ updates could further expand the definition of a [=push subscription owner=] to encompass
+ additional types, further broadening the range of possible implementations.
A push subscription has an associated push endpoint. It MUST be the
@@ -209,7 +226,8 @@
To create a push subscription, given an {{PushSubscriptionOptionsInit}}
- |optionsDictionary:PushSubscriptionOptionsInit|:
+ |optionsDictionary:PushSubscriptionOptionsInit| and a [=environment settings object=]
+ |environment|:
- Let |subscription:PushSubscription| be a new {{PushSubscription}}.
@@ -231,9 +249,9 @@
key can be retrieved by calling the {{PushSubscription/getKey()}} method of the
{{PushSubscription}} with an argument of {{PushEncryptionKeyName/"auth"}}.
- - Request a new push subscription. Include the
+
- Request a new push subscription. Include the
{{PushSubscriptionOptions/applicationServerKey}} attribute of |options| when it has been
- set. Rethrow any [=exceptions=].
+ set. [=Exception/Throws|Rethrow=] any [=exceptions=].
- When the push subscription request has completed successfully:
@@ -245,6 +263,8 @@
+ Associate |subscription| with the |environment|.
+
Return |subscription|.
@@ -527,6 +547,17 @@
+
+
+ Extensions to the `Navigator` interface
+
+
+ [SecureContext]
+ partial interface Navigator {
+ [SameObject] readonly attribute PushManager pushManager;
+ };
+
+
Extensions to the `ServiceWorkerRegistration` Interface
@@ -584,7 +615,7 @@
- Let |promise| be [=a new promise=].
- - Let |global| be [=this=]' [=relevant global object=].
+
- Let |global| be the [=relevant global object=] for [=this=].
- Return |promise| and continue [=in parallel=].
-
Let |registration:ServiceWorkerRegistration| be [=this=]'s associated service worker
- registration.
+ Let |environment| be the [=relevant settings object=] for |global|.
- If |registration|'s [=service worker registration/active worker=] is null, [=queue a
- global task=] on the [=networking task source=] using |global| to [=reject=] |promise| with
- an {{"InvalidStateError"}} {{DOMException}} and terminate these steps.
+ Let |sw| be the |environment|'s [=environment/active service worker=].
- Let |sw| be |registration|'s [=service worker registration/active worker=].
+ If |sw| is null and |global| is a {{ServiceWorkerRegistration}}, [=queue a global
+ task=] on the [=networking task source=] using |global| to [=reject=] |promise| with an
+ {{"InvalidStateError"}} {{DOMException}} and terminate these steps.
Let |permission| be [=request permission to use=] "push".
@@ -642,18 +672,16 @@
interaction task source=] using |global| to [=reject=] |promise| with a
{{"NotAllowedError"}} {{DOMException}} and terminate these steps.
-
If |sw| is already subscribed, run the following sub-steps:
+ Let |subscription:PushSubscription| be the result of attempting to retrieve the push
+ subscription associated with the |environment|. If there is an error, [=queue a global
+ task=] on the [=networking task source=] using |global| to [=reject=] |promise| with an
+ {{"AbortError"}} {{DOMException}} and terminate these steps.
+
+ If |subscription| is not null, run the following sub-steps:
- - Try to retrieve the push subscription associated with the |sw|. If there is
- an error, [=queue a global task=] on the [=networking task source=] using |global| to
- [=reject=] |promise| with an {{"AbortError"}} {{DOMException}} and terminate these
- steps.
-
- - Let |subscription| be the push subscription associated with |sw|.
-
- - Compare the |options| argument with the `options` attribute of |subscription|. The
- contents of {{BufferSource}} values are compared for equality rather than
- [=ECMAScript/reference record|reference=].
+
- Compare the |options| argument with |subscription|'s {PushSubscription/options}
+ attribute. The contents of {{BufferSource}} values are compared for equality rather
+ than [=ECMAScript/reference record|reference=].
- If any attribute on |options| contains a different value to that stored for
|subscription|, then [=queue a global task=] on the [=networking task source=] using
@@ -666,34 +694,45 @@
- Let |subscription| be the result of trying to [=create a push subscription=] with
- |options|. If creating the subscription [=exception/throws=] an [=exception=], [=queue a
- global task=] on the [=networking task source=] using |global| to [=reject=] |promise| with
- a that [=exception=] and terminate these these steps.
+ Otherwise, let |newSubscription| be the result of trying to [=create a push
+ subscription=] with |options| and |environment|. If creating the subscription
+ [=exception/throws=] an [=exception=], [=queue a global task=] on the [=networking task
+ source=] using |global| to [=reject=] |promise| with that [=exception=] and terminate these
+ steps.
Otherwise, [=queue a global task=] on the [=networking task source=] using |global| to
- [=resolve=] |promise| with a {{PushSubscription}} providing the details of the new
- |subscription|.
+ [=resolve=] |promise| with |newSubscription|.
- The getSubscription method when invoked MUST run the
- following steps:
+ The getSubscription() method when invoked MUST run
+ the following steps:
- Let |promise| be a new promise.
- - Return |promise| and continue the following steps asynchronously.
+
- Let |global| be the [=relevant global object=] for [=this=].
+
+ - Let |environment| be the [=relevant settings object=] for |global|.
+
+ - Return |promise| and continue the following steps [=in parallel=].
+
+ - If |global| is a {{ServiceWorkerGlobalScope}}, let |owner| be |global|'s associated
+ [=service worker registration=]. Otherwise, let |owner| be the [=relevant settings object=]
+ for |global|.
- - If the Service Worker is not subscribed, resolve |promise| with null.
+
- If the |owner| is not subscribed, [=queue a global task=] on the [=networking task
+ source=] using |global| to [=resolve=] |promise| with null and terminate these steps.
- - Retrieve the push subscription associated with the Service Worker.
+
- let |subscription:PushSubscription| be the result of attempting to retrieve the [=push
+ subscription=] associated with the |owner|.
- - If there is an error, reject |promise| with a {{DOMException}} whose name is
- {{"AbortError"}} and terminate these steps.
+
- If there is an error, [=queue a global task=] on the [=networking task source=] using
+ |global| to [=reject=] |promise| with a {{"AbortError"}} {{DOMException}} and terminate
+ these steps.
- - When the request has been completed, resolve |promise| with a {{PushSubscription}}
- providing the details of the retrieved push subscription.
+
- Otherwise, when the retrieve request has been completed, [=queue a global task=] on the
+ [=networking task source=] using |global| to [=resolve=] |promise| with the |subscription|.
@@ -703,14 +742,17 @@
- Let |promise| be a new promise.
- - Return |promise| and continue the following steps asynchronously.
+
- Let |global| be [=this=]' [=relevant global object=].
+
+ - Return |promise| and continue the following [=in parallel=].
- Let |descriptor| be a new {{PermissionDescriptor}} with the
- {{PermissionDescriptor/name}}} initialized to "push".
+ {{PermissionDescriptor/name}} initialized to "push".
- - let |state| be the [=permission state=] of |descriptor| and the result.
+
- Let |state| be the [=permission state=] of |descriptor|.
- - Resolve |promise| with |state|.
+
- [=Queue a global task=] on the [=DOM manipulation task source=] given |global| to
+ [=resolve=] |promise| with |state|.