1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3* License, v. 2.0. If a copy of the MPL was not distributed with this file,
4* You can obtain one at http://mozilla.org/MPL/2.0/.
5*
6* The origin of this IDL file is
7* https://w3c.github.io/push-api/
8*/
9
10interface Principal;
11
12enum PushEncryptionKeyName
13{
14  "p256dh",
15  "auth"
16};
17
18dictionary PushSubscriptionKeys
19{
20  ByteString p256dh;
21  ByteString auth;
22};
23
24dictionary PushSubscriptionJSON
25{
26  USVString endpoint;
27  // FIXME: bug 1493860: should this "= {}" be here?  For that matter, this
28  // PushSubscriptionKeys thing is not even in the spec; "keys" is a record
29  // there.
30  PushSubscriptionKeys keys = {};
31  EpochTimeStamp? expirationTime;
32};
33
34dictionary PushSubscriptionInit
35{
36  required USVString endpoint;
37  required USVString scope;
38  ArrayBuffer? p256dhKey;
39  ArrayBuffer? authSecret;
40  BufferSource? appServerKey;
41  EpochTimeStamp? expirationTime = null;
42};
43
44[Exposed=(Window,Worker), Pref="dom.push.enabled"]
45interface PushSubscription
46{
47  [Throws, ChromeOnly]
48  constructor(PushSubscriptionInit initDict);
49
50  readonly attribute USVString endpoint;
51  readonly attribute PushSubscriptionOptions options;
52  readonly attribute EpochTimeStamp? expirationTime;
53  [Throws]
54  ArrayBuffer? getKey(PushEncryptionKeyName name);
55  [Throws, UseCounter]
56  Promise<boolean> unsubscribe();
57
58  // Implements the custom serializer specified in Push API, section 9.
59  [Throws]
60  PushSubscriptionJSON toJSON();
61};
62