diff --git a/index.html b/index.html index 9fbeca9..0d328d2 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,8 +172,32 @@

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 - service worker registration has at most one push subscription. + push subscription is associated with a [=push subscription owner=]. +

+

+ 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. +
+
+

+ 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 @@ -202,7 +226,8 @@

To create a push subscription, given an {{PushSubscriptionOptionsInit}} - |optionsDictionary:PushSubscriptionOptionsInit|: + |optionsDictionary:PushSubscriptionOptionsInit| and a [=environment settings object=] + |environment|:

  1. Let |subscription:PushSubscription| be a new {{PushSubscription}}. @@ -224,9 +249,9 @@

    key can be retrieved by calling the {{PushSubscription/getKey()}} method of the {{PushSubscription}} with an argument of {{PushEncryptionKeyName/"auth"}}.

  2. -
  3. Request a new push subscription. Include the +
  4. 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=].
  5. When the push subscription request has completed successfully:
      @@ -238,6 +263,8 @@

  6. +
  7. Associate |subscription| with the |environment|. +
  8. Return |subscription|.
@@ -431,13 +458,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. @@ -520,6 +547,17 @@

    +
    +

    + Extensions to the `Navigator` interface +

    +
    +        [SecureContext]
    +        partial interface Navigator {
    +          [SameObject] readonly attribute PushManager pushManager;
    +        };
    +      
    +

    Extensions to the `ServiceWorkerRegistration` Interface @@ -577,7 +615,7 @@

    1. Let |promise| be [=a new promise=].
    2. -
    3. Let |global| be [=this=]' [=relevant global object=]. +
    4. Let |global| be the [=relevant global object=] for [=this=].
    5. 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".
  • @@ -635,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:
      -
    1. 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. -
    2. -
    3. Let |subscription| be the push subscription associated with |sw|. -
    4. -
    5. 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=]. +
    6. 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=].
    7. 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 @@ -659,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:

    1. Let |promise| be a new promise.
    2. -
    3. Return |promise| and continue the following steps asynchronously. +
    4. Let |global| be the [=relevant global object=] for [=this=]. +
    5. +
    6. Let |environment| be the [=relevant settings object=] for |global|. +
    7. +
    8. Return |promise| and continue the following steps [=in parallel=].
    9. -
    10. If the Service Worker is not subscribed, resolve |promise| with null. +
    11. If |global| is a {{ServiceWorkerGlobalScope}}, let |owner| be |global|'s associated + [=service worker registration=]. Otherwise, let |owner| be the [=relevant settings object=] + for |global|.
    12. -
    13. Retrieve the push subscription associated with the Service Worker. +
    14. 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.
    15. -
    16. If there is an error, reject |promise| with a {{DOMException}} whose name is - {{"AbortError"}} and terminate these steps. +
    17. let |subscription:PushSubscription| be the result of attempting to retrieve the [=push + subscription=] associated with the |owner|.
    18. -
    19. When the request has been completed, resolve |promise| with a {{PushSubscription}} - providing the details of the retrieved push subscription. +
    20. 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. +
    21. +
    22. 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|.

    @@ -696,14 +742,17 @@

    1. Let |promise| be a new promise.
    2. -
    3. Return |promise| and continue the following steps asynchronously. +
    4. Let |global| be [=this=]' [=relevant global object=]. +
    5. +
    6. Return |promise| and continue the following [=in parallel=].
    7. Let |descriptor| be a new {{PermissionDescriptor}} with the - {{PermissionDescriptor/name}}} initialized to "push". + {{PermissionDescriptor/name}} initialized to "push".
    8. -
    9. let |state| be the [=permission state=] of |descriptor| and the result. +
    10. Let |state| be the [=permission state=] of |descriptor|.
    11. -
    12. Resolve |promise| with |state|. +
    13. [=Queue a global task=] on the [=DOM manipulation task source=] given |global| to + [=resolve=] |promise| with |state|.