web_common.mli 3.5 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
val contact_uri : string option ref
28

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

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

exception Error of error

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

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

51 52 53 54 55
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. *)
56 57 58

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

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

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

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

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

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

89
val generate_token : ?length:int -> unit -> string Lwt.t
90 91

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

93
val underscorize : uuid -> string
94

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

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

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

val is_email : string -> bool
105 106 107

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