This repository has no description
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** JMAP push types as defined in RFC 8620 Section 7
7
8 @canonical Jmap.Proto.Push *)
9
10(** {1 StateChange} *)
11
12(** A state change notification for push. *)
13module State_change : sig
14 type type_state = {
15 type_name : string;
16 (** The data type that changed (e.g., "Email", "Mailbox"). *)
17 state : string;
18 (** The new state string for this type. *)
19 }
20
21 type t = {
22 type_ : string;
23 (** Always "StateChange". *)
24 changed : (Proto_id.t * type_state list) list;
25 (** Map of account id to list of type state changes. *)
26 }
27
28 val jsont : t Jsont.t
29end
30
31(** {1 PushSubscription} *)
32
33(** Web push subscription keys. *)
34type push_keys = {
35 p256dh : string;
36 (** P-256 ECDH public key as URL-safe base64. *)
37 auth : string;
38 (** Authentication secret as URL-safe base64. *)
39}
40
41val push_keys_jsont : push_keys Jsont.t
42
43(** A push subscription object. *)
44type t = {
45 id : Proto_id.t;
46 (** Server-assigned subscription id. *)
47 device_client_id : string;
48 (** Client-provided device identifier. *)
49 url : string;
50 (** The push endpoint URL. *)
51 keys : push_keys option;
52 (** Optional encryption keys for Web Push. *)
53 verification_code : string option;
54 (** Code for verifying subscription ownership. *)
55 expires : Ptime.t option;
56 (** When the subscription expires. *)
57 types : string list option;
58 (** Data types to receive notifications for. [None] means all. *)
59}
60
61val id : t -> Proto_id.t
62val device_client_id : t -> string
63val url : t -> string
64val keys : t -> push_keys option
65val verification_code : t -> string option
66val expires : t -> Ptime.t option
67val types : t -> string list option
68
69val jsont : t Jsont.t
70(** JSON codec for PushSubscription. *)
71
72(** {1 PushSubscription Methods} *)
73
74(** Arguments for PushSubscription/get. *)
75val get_args_jsont : Proto_method.get_args Jsont.t
76
77(** Response for PushSubscription/get. *)
78val get_response_jsont : t Proto_method.get_response Jsont.t
79
80(** Arguments for PushSubscription/set. *)
81type set_args = {
82 account_id : Proto_id.t option;
83 (** Not used for PushSubscription. *)
84 if_in_state : string option;
85 create : (Proto_id.t * create_args) list option;
86 update : (Proto_id.t * Jsont.json) list option;
87 destroy : Proto_id.t list option;
88}
89
90and create_args = {
91 device_client_id : string;
92 url : string;
93 keys : push_keys option;
94 verification_code : string option;
95 types : string list option;
96}
97
98val set_args_jsont : set_args Jsont.t