diff --git a/index.html b/index.html index 7016956..2a41b64 100644 --- a/index.html +++ b/index.html @@ -164,6 +164,281 @@

service worker is not currently running, the worker is started to enable delivery.

+
+

+ Declarative push message +

+

+ A declarative push message is a [=push message=] whose data is encoded in such + a way that it results in some automatic action on behalf of the web application. E.g., + the creation and display of a notification. +

+

+ A [=declarative push message=] is a JSON document that contains the instructions to + create and display a notification. +

+
+          {
+            "web_push": 9001,
+            "notification": {
+              "title": "Watch the new season of Return of the Example now!",
+              "lang": "en-US",
+              "dir": "ltr",
+              "body": "The examples are going to great lengths once more.",
+              "url": "https://tv.example/return"
+            }
+          }
+        
+
+

+ Members +

+

+ A [=declarative push message=] has the following members: +

+
+
+ web_push (required) +
+
+

+ An integer that must be 9001. Used to disambiguate a [=declarative push message=] + from other JSON documents. +

+
+
+ notification (required) +
+
+

+ A JSON object consisting of the following members, many being analogous to + Notifications API features. +

+
+
+ title (required) +
+
+

+ A string. +

+
+
+ dir +
+
+

+ "auto", "ltr", or "rtl". +

+
+
+ lang +
+
+

+ A string that holds a language tag. +

+
+
+ body +
+
+

+ A string. +

+
+
+ url (required) +
+
+

+ A string that holds a URL. +

+
+
+ tag +
+
+

+ A string. +

+
+
+ icon +
+
+

+ A string that holds a URL. +

+
+
+ silent +
+
+

+ A boolean. +

+
+
+ data +
+
+

+ Any JSON value. +

+
+
+ mutable +
+
+

+ A boolean. When true causes a pushnotification to be dispatched to + a service worker (if any). +

+
+
+
+
+ app_badge +
+
+

+ An integer in the range 0 to 9223372036854775807, inclusive. +

+
+
+
+
+

+ Parser +

+

+ A declarative push message parser result is a [=/tuple=] consisting of a + notification (a + [=/notification=]), mutable + notification (a boolean), and an app badge (null or an integer). +

+

+ The declarative push message parser given a [=/byte sequence=] + bytes, [=/origin=] origin, [=/URL=] baseURL, and + {{EpochTimestamp}} fallbackTimestamp runs these steps. They return failure + or a [=/declarative push message parser result=]. +

+
    +
  1. +

    + Let message be the result of [=parsing JSON bytes to an Infra value=] + given bytes. If that throws an exception, then return failure. +

    +
  2. +
  3. +

    + If message is not a [=/map=], then return failure. +

    +
  4. +
  5. +

    + If message["`web_push`"] [=map/does not exist=], then return failure. +

    +
  6. +
  7. +

    + If message["`web_push`"] is not 9001, then return failure. +

    +
  8. +
  9. +

    + If message["`notification`"] [=map/does not exist=], then return + failure. +

    +
  10. +
  11. +

    + Let notificationInput be message["`notification`"]. +

    +
  12. +
  13. +

    + If notificationInput is not a [=/map=], then return failure. +

    +
  14. +
  15. +

    + If notificationInput["`title`"] [=map/does not exist=], then return + failure. +

    +
  16. +
  17. +

    + If notificationInput["`title`"] is not a string, then return failure. +

    +
  18. +
  19. +

    + Let title be notificationInput["`title`"]. +

    +
  20. +
  21. +

    + Let mutable be false. +

    +
  22. +
  23. +

    + If notificationInput["`mutable`"] [=map/exists=] and + notificationInput["`mutable`"] is a boolean, then set mutable + to notificationInput["`mutable`"]. +

    +
  24. +
  25. +

    + Let jsNotificationInput be the result of running convert an Infra + value to a JSON-compatible JavaScript value given notificationInput. +

    +
  26. +
  27. +

    + Let notificationOptions be the result of converting jsNotificationInput to the + dictionary type {{NotificationOptions}}. If this throws an exception, then return + failure. +

    +
  28. +
  29. +

    + Let notification be the result of creating a notification given + title, notificationOptions, origin, + baseURL, and fallbackTimestamp. If this throws an exception, + then return failure. +

    +
  30. +
  31. +

    + If notification's [=notification/URL=] is null, then return failure. +

    +
  32. +
  33. +

    + Let appBadge be null. +

    +
  34. +
  35. +

    + If message["`app_badge`"] [=map/exists=] and + message["`app_badge`"] is an integer in the range 0 to + 9223372036854775807, inclusive, then set appBadge to + message["`app_badge`"]. +

    +
  36. +
  37. +

    + Return (notification, mutable, appBadge). +

    +
  38. +
+
+

Push subscription @@ -1111,6 +1386,30 @@

`null` in all other cases.

+
+

+ PushNotificationEvent Interface +

+
+            [Exposed=ServiceWorker, SecureContext]
+            interface PushNotificationEvent : ExtendableEvent {
+              constructor(DOMString type, optional PushNotificationEventInit eventInitDict = {});
+              readonly attribute Notification notification;
+              readonly attribute unsigned long long? appBadge;
+            };
+
+            dictionary PushNotificationEventInit : ExtendableEventInit {
+              required Notification notification;
+              unsigned long long? appBadge = null;
+            };
+          
+

+ The notification attribute must return the value it was initialized with. +

+

+ The appBadge attribute must return the value it was initialized with. +

+

Receiving a Push Message @@ -1127,13 +1426,13 @@

  • Let |subscription| be the active push subscription for |registration|.
  • -
  • Initialize |data| to a value of `null`. +
  • Let |bytes| be null.
  • If the push message contains a payload, perform the following steps:
      -
    1. Decrypt the push message using the private key from the key pair - associated with |subscription| and the process described in [[RFC8291]]. This - produces the plain text of the message. +
    2. Decrypt the push message's payload using the private key from the key pair + associated with |subscription| and the process described in [[RFC8291]]. Set |bytes| + to the resulting [=/byte sequence=].
    3. If the push message could not be decrypted for any reason, perform the following steps: @@ -1145,14 +1444,118 @@

    4. Discard the push message.
    5. -
    6. Terminate this process. +
    7. Abort these steps.
    8. -
    A `push` event MUST NOT be fired for a push message that was not - successfully decrypted using the key pair associated with the push - subscription. + +

    + A `push` event is not fired for a push message that was not successfully + decrypted using the key pair associated with the push subscription. +

  • -
  • Let |data| be a new PushMessageData instance with the decrypted plain text - of the push message. + +
  • +
  • +

    + If |bytes| is non-null: +

    +
      +
    1. +

      + Let |baseURL| be |registration|'s [=service worker registration/scope URL=]. +

      +
    2. +
    3. +

      + Let |origin| be |baseURL|'s [=url/origin=]. +

      +
    4. +
    5. +

      + Let |fallbackTimestamp| be w3c/hr-time #165. +

      +
    6. +
    7. +

      + Let |declarativeResult| be the result of running the [=/declarative push message + parser=] given |bytes|, |origin|, |baseURL|, and |fallbackTimestamp|. +

      +
    8. +
    9. +

      + If |declarativeResult| is not failure: +

      +
        +
      1. +

        + Let |notification| be |declarativeResult|'s [=declarative push message parser + result/notification=]. +

        +
      2. +
      3. +

        + Set |notification|'s [=notification/service worker registration=] to + |registration|. +

        +
      4. +
      5. +

        + If |declarativeResult|'s [=declarative push message parser result/mutable + notification=] is true: +

        +
          +
        1. +

          + [=/Fire a functional event=] named "`pushnotification`" using + {{PushNotificationEvent}} on |registration| with the following + properties: +

          +
          +
          + `notification` +
          +
          + |notification| +
          +
          + `appBadge` +
          +
          + |declarativeResult|'s [=declarative push message parser result/app + badge=] +
          +
          +
        2. +
        3. +

          + Wait for all of the promises in the [=ExtendableEvent/extend lifetime + promises=] of the dispatched event to resolve. +

          +
        4. +
        5. +

          + If a notification has been shown through {{showNotification()}} at this + point, then abort these steps. +

          +
        6. +
        +
      6. +
      7. +

        + Run the [=notification show steps=] given |notification|. +

        +
      8. +
      9. +

        + w3c/badging #111 +

        +
      10. +
      11. +

        + Abort these steps. +

        +
      12. +
  • @@ -1166,7 +1569,7 @@

    `data`
    - |data| + A new PushMessageData instance whose [=PushMessageData/bytes=] is |bytes|.