web_common.mli 3.45 KB
Newer Older
Stephane Glondu's avatar
Stephane Glondu committed
1 2 3
(**************************************************************************)
(*                                BELENIOS                                *)
(*                                                                        *)
Stephane Glondu's avatar
Stephane Glondu committed
4
(*  Copyright © 2012-2016 Inria                                           *)
Stephane Glondu's avatar
Stephane Glondu committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(*                                                                        *)
(*  This program is free software: you can redistribute it and/or modify  *)
(*  it under the terms of the GNU Affero General Public License as        *)
(*  published by the Free Software Foundation, either version 3 of the    *)
(*  License, or (at your option) any later version, with the additional   *)
(*  exemption that compiling, linking, and/or using OpenSSL is allowed.   *)
(*                                                                        *)
(*  This program is distributed in the hope that it will be useful, but   *)
(*  WITHOUT ANY WARRANTY; without even the implied warranty of            *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *)
(*  Affero General Public License for more details.                       *)
(*                                                                        *)
(*  You should have received a copy of the GNU Affero General Public      *)
(*  License along with this program.  If not, see                         *)
(*  <http://www.gnu.org/licenses/>.                                       *)
(**************************************************************************)

Stephane Glondu's avatar
Stephane Glondu committed
22
open Signatures
Stephane Glondu's avatar
Stephane Glondu committed
23
open Web_serializable_t
24

25
val spool_dir : string ref
26
val server_mail : string ref
27

Stephane Glondu's avatar
Stephane Glondu committed
28
module LwtRandom : RANDOM with type 'a t = 'a Lwt.t
29 30
(** Lwt-compatible random number generation. *)

31
type error =
32 33 34 35 36 37 38 39
  | Serialization of exn
  | ProofCheck
  | ElectionClosed
  | MissingCredential
  | InvalidCredential
  | RevoteNotAllowed
  | ReusedCredential
  | WrongCredential
Stephane Glondu's avatar
Stephane Glondu committed
40 41
  | UsedCredential
  | CredentialNotFound
42
  | UnauthorizedVoter
43 44 45

exception Error of error

46
val fail : error -> 'a Lwt.t
47

48
val explain_error : error -> string
Stephane Glondu's avatar
Stephane Glondu committed
49

50 51 52 53 54
val open_security_log : string -> unit Lwt.t
(** Set the path to the security logger. *)

val security_log : (unit -> string) -> unit Lwt.t
(** Add an entry to the security log. *)
55 56 57

val fail_http : int -> 'a Lwt.t
val forbidden : unit -> 'a Lwt.t
58 59 60

val rewrite_prefix : string -> string
val set_rewrite_prefix : src:string -> dst:string -> unit
Stephane Glondu's avatar
Stephane Glondu committed
61

62 63 64
type election_file =
  | ESRaw
  | ESKeys
65
  | ESTParams
66 67
  | ESCreds
  | ESBallots
Stephane Glondu's avatar
Stephane Glondu committed
68
  | ESVoters
69
  | ESRecords
70
  | ESETally
71
  | ESResult
72 73 74

val election_file_of_string : string -> election_file
val string_of_election_file : election_file -> string
75 76 77 78 79 80

val election_file :
  string ->
  (election_file, [ `WithoutSuffix ],
   [ `One of election_file ] Eliom_parameter.param_name)
  Eliom_parameter.params_type
81 82 83

val uuid :
  string ->
84 85
  (uuid, [ `WithoutSuffix ],
   [ `One of uuid ] Eliom_parameter.param_name)
86 87 88
  Eliom_parameter.params_type

val generate_token : unit -> string Lwt.t
89 90

val string_of_user : user -> string
Stephane Glondu's avatar
Stephane Glondu committed
91

92
val underscorize : uuid -> string
93

94
val send_email : string -> string -> string -> unit Lwt.t
95 96

val split_identity : string -> string * string
Stephane Glondu's avatar
Stephane Glondu committed
97

98
val available_languages : string list
99 100
val get_languages : string list option -> string list
val string_of_languages : string list option -> string
Stephane Glondu's avatar
Stephane Glondu committed
101
val languages_of_string : string -> string list
102 103

val is_email : string -> bool
104 105 106

val read_file : ?uuid:uuid -> string -> string list option Lwt.t
val write_file : ?uuid:uuid -> string -> string list -> unit Lwt.t