-> hardcode config
This commit is contained in:
parent
a99eefc9e5
commit
592ebee9a3
4 changed files with 108 additions and 30 deletions
|
|
@ -8,7 +8,6 @@
|
||||||
https://docs.taler.net/design-documents/003-tos-rendering.html *)
|
https://docs.taler.net/design-documents/003-tos-rendering.html *)
|
||||||
|
|
||||||
(* hardcoded config just for static assets *)
|
(* hardcoded config just for static assets *)
|
||||||
module Config = struct
|
|
||||||
let default_lang = "en"
|
let default_lang = "en"
|
||||||
let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity
|
let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity
|
||||||
|
|
||||||
|
|
@ -16,16 +15,8 @@ module Config = struct
|
||||||
supported, according to DD we take text/plain as default instead for now *)
|
supported, according to DD we take text/plain as default instead for now *)
|
||||||
let default_mimetype = ("text", "plain")
|
let default_mimetype = ("text", "plain")
|
||||||
let default_extension = ".txt"
|
let default_extension = ".txt"
|
||||||
let terms_dir = Fpath.(v "terms")
|
|
||||||
let privacy_dir = Fpath.(v "privacy")
|
|
||||||
|
|
||||||
(* ETAG is used as base filename it should be encoded in Crockford base-32 we do
|
|
||||||
not generate it and we do not verify it *)
|
|
||||||
let terms_etag = "0" |> Headers_lib.Etag.of_crockford32 |> Result.get_ok
|
|
||||||
let privacy_etag = "0" |> Headers_lib.Etag.of_crockford32 |> Result.get_ok
|
|
||||||
let terms_legal_version = "1"
|
let terms_legal_version = "1"
|
||||||
let privacy_legal_version = "1"
|
let privacy_legal_version = "1"
|
||||||
end
|
|
||||||
|
|
||||||
module Mimetype = struct
|
module Mimetype = struct
|
||||||
let mimetype_extension_assoc =
|
let mimetype_extension_assoc =
|
||||||
|
|
@ -44,7 +35,7 @@ module Mimetype = struct
|
||||||
List.find_opt (( = ) (m, m_sub)) mimetype_l
|
List.find_opt (( = ) (m, m_sub)) mimetype_l
|
||||||
| AnyMediaSubtype m ->
|
| AnyMediaSubtype m ->
|
||||||
List.find_opt (fun (m', _) -> String.equal m m') mimetype_l
|
List.find_opt (fun (m', _) -> String.equal m m') mimetype_l
|
||||||
| AnyMedia -> Some Config.default_mimetype
|
| AnyMedia -> Some default_mimetype
|
||||||
|
|
||||||
let to_extension (m, m_sub) =
|
let to_extension (m, m_sub) =
|
||||||
assert (m <> "*");
|
assert (m <> "*");
|
||||||
|
|
@ -65,16 +56,16 @@ type t =
|
||||||
| Privacy
|
| Privacy
|
||||||
|
|
||||||
let etag = function
|
let etag = function
|
||||||
| Terms -> Config.terms_etag
|
| Terms -> Config.Exchange.terms_etag
|
||||||
| Privacy -> Config.privacy_etag
|
| Privacy -> Config.Exchange.privacy_etag
|
||||||
|
|
||||||
let legal_version = function
|
let legal_version = function
|
||||||
| Terms -> Config.terms_legal_version
|
| Terms -> terms_legal_version
|
||||||
| Privacy -> Config.privacy_legal_version
|
| Privacy -> privacy_legal_version
|
||||||
|
|
||||||
let base_dir = function
|
let base_dir = function
|
||||||
| Terms -> Config.terms_dir
|
| Terms -> Config.Exchange.terms_dir
|
||||||
| Privacy -> Config.privacy_dir
|
| Privacy -> Config.Exchange.privacy_dir
|
||||||
|
|
||||||
(* TODO
|
(* TODO
|
||||||
better use of Fmt to have error prefix or smthing
|
better use of Fmt to have error prefix or smthing
|
||||||
|
|
@ -107,8 +98,8 @@ let supported_lang_arr, supported_ext_arr =
|
||||||
let () =
|
let () =
|
||||||
if List.is_empty lang_l then Fmt.failwith "no language supported";
|
if List.is_empty lang_l then Fmt.failwith "no language supported";
|
||||||
if List.is_empty ext_l then Fmt.failwith "no mimetype supported";
|
if List.is_empty ext_l then Fmt.failwith "no mimetype supported";
|
||||||
if not @@ List.mem Config.default_lang lang_l then
|
if not @@ List.mem default_lang lang_l then
|
||||||
Fmt.failwith "default language `%s` files not found" Config.default_lang;
|
Fmt.failwith "default language `%s` files not found" default_lang;
|
||||||
if not @@ List.mem ".txt" ext_l then
|
if not @@ List.mem ".txt" ext_l then
|
||||||
Fmt.failwith "plain text file not found";
|
Fmt.failwith "plain text file not found";
|
||||||
if not @@ List.mem ".md" ext_l then Fmt.failwith "markdown file not found";
|
if not @@ List.mem ".md" ext_l then Fmt.failwith "markdown file not found";
|
||||||
|
|
|
||||||
87
src/config.ml
Normal file
87
src/config.ml
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
(* hardcoded config for now *)
|
||||||
|
|
||||||
|
let amount s = Amount.of_string s |> Result.get_ok
|
||||||
|
|
||||||
|
module Exchange = struct
|
||||||
|
let currency = "EUR"
|
||||||
|
let currency_round_unit = amount "EUR:0.01"
|
||||||
|
let db = "postgres"
|
||||||
|
let attribute_encryption_key = "uhuhg" (* high-entropy nonce. *)
|
||||||
|
let port = 3696
|
||||||
|
let master_public_key = "uhuhg"
|
||||||
|
let stefan_abs = amount "EUR:0.00"
|
||||||
|
let stefan_log = amount "EUR:0.00"
|
||||||
|
let stefan_lin = 0.0
|
||||||
|
let signkey_legal_duration = 99999999
|
||||||
|
let max_keys_caching = 9999999
|
||||||
|
let max_requests = 99999999
|
||||||
|
let terms_dir = Fpath.(v "terms")
|
||||||
|
let terms_etag = "0" |> Headers_lib.Etag.of_crockford32 |> Result.get_ok
|
||||||
|
let privacy_dir = Fpath.(v "privacy")
|
||||||
|
let privacy_etag = "0" |> Headers_lib.Etag.of_crockford32 |> Result.get_ok
|
||||||
|
let enable_kyc = `NO
|
||||||
|
end
|
||||||
|
|
||||||
|
type currency = {
|
||||||
|
enabled: [ `YES | `NO ];
|
||||||
|
code: string;
|
||||||
|
name: string;
|
||||||
|
fractional_input_digits: int;
|
||||||
|
fractional_normal_digits: int;
|
||||||
|
fractional_trailing_zero_digits: int;
|
||||||
|
alt_unit_names: (int * string) list;
|
||||||
|
}
|
||||||
|
|
||||||
|
let currency_eur =
|
||||||
|
{
|
||||||
|
enabled= `NO;
|
||||||
|
code= "EUR";
|
||||||
|
name= "euro";
|
||||||
|
fractional_input_digits= 2;
|
||||||
|
fractional_normal_digits= 2;
|
||||||
|
fractional_trailing_zero_digits= 2;
|
||||||
|
alt_unit_names= [ (0, "E"); (3, "kE") ];
|
||||||
|
}
|
||||||
|
|
||||||
|
module Secmod_rsa = struct
|
||||||
|
let lookahead_sign = 9999999
|
||||||
|
let overlap_duration = 9999999
|
||||||
|
let sm_priv_key = Fpath.(v "rsa_key.priv")
|
||||||
|
let key_dir = Fpath.(v "rsa")
|
||||||
|
end
|
||||||
|
|
||||||
|
module Secmod_eddsa = struct
|
||||||
|
let lookahead_sign = 9999999
|
||||||
|
let overlap_duration = 9999999
|
||||||
|
let sm_priv_key = Fpath.(v "eddsa_key.priv")
|
||||||
|
let key_dir = Fpath.(v "eddsa")
|
||||||
|
end
|
||||||
|
|
||||||
|
type coin = {
|
||||||
|
value: Amount.t;
|
||||||
|
duration_withdraw: int;
|
||||||
|
duration_spend: int;
|
||||||
|
duration_legal: int;
|
||||||
|
fee_withdraw: Amount.t;
|
||||||
|
fee_deposit: Amount.t;
|
||||||
|
fee_refresh: Amount.t;
|
||||||
|
fee_refund: Amount.t;
|
||||||
|
cipher: [ (* `CS |*) `RSA ];
|
||||||
|
rsa_keysize: int option (*only if `RSA *);
|
||||||
|
age_restricted: [ (*`YES|*) `NO ];
|
||||||
|
}
|
||||||
|
|
||||||
|
let coin_kudo =
|
||||||
|
{
|
||||||
|
value= amount "EUR:0.01";
|
||||||
|
duration_withdraw= 999999;
|
||||||
|
duration_spend= 999999;
|
||||||
|
duration_legal= 999999;
|
||||||
|
fee_withdraw= amount "EUR:0.00";
|
||||||
|
fee_deposit= amount "EUR:0.00";
|
||||||
|
fee_refresh= amount "EUR:0.00";
|
||||||
|
fee_refund= amount "EUR:0.00";
|
||||||
|
cipher= `RSA;
|
||||||
|
rsa_keysize= Some 2048;
|
||||||
|
age_restricted= `NO;
|
||||||
|
}
|
||||||
|
|
@ -25,14 +25,14 @@ let select_language headers =
|
||||||
|> Cohttp.Accept.qsort
|
|> Cohttp.Accept.qsort
|
||||||
|> List.map (fun (_q, lang) -> lang)
|
|> List.map (fun (_q, lang) -> lang)
|
||||||
|> List.map (function
|
|> List.map (function
|
||||||
| Cohttp.Accept.AnyLanguage -> Assets.Config.default_lang
|
| Cohttp.Accept.AnyLanguage -> Assets.default_lang
|
||||||
| Language language_range -> (
|
| Language language_range -> (
|
||||||
(* ignore language subtags (e.g. "en-US" -> "en") *)
|
(* ignore language subtags (e.g. "en-US" -> "en") *)
|
||||||
match language_range with
|
match language_range with
|
||||||
| [] -> assert false
|
| [] -> assert false
|
||||||
| primary_tag :: _ -> primary_tag))
|
| primary_tag :: _ -> primary_tag))
|
||||||
|> List.find_opt Assets.is_supported_lang
|
|> List.find_opt Assets.is_supported_lang
|
||||||
|> Option.value ~default:Assets.Config.default_lang
|
|> Option.value ~default:Assets.default_lang
|
||||||
|
|
||||||
let select_encoding headers =
|
let select_encoding headers =
|
||||||
Vif.Headers.get headers "accept-encoding"
|
Vif.Headers.get headers "accept-encoding"
|
||||||
|
|
@ -43,7 +43,7 @@ let select_encoding headers =
|
||||||
| Cohttp.Accept.Identity -> Some `Identity
|
| Cohttp.Accept.Identity -> Some `Identity
|
||||||
| Deflate -> Some `DEFLATE
|
| Deflate -> Some `DEFLATE
|
||||||
| Gzip -> Some `Gzip
|
| Gzip -> Some `Gzip
|
||||||
| AnyEncoding -> Some Assets.Config.default_encoding
|
| AnyEncoding -> Some Assets.default_encoding
|
||||||
| Encoding _ | Compress -> (* unsupported *) None)
|
| Encoding _ | Compress -> (* unsupported *) None)
|
||||||
|> function
|
|> function
|
||||||
| [] -> assert false
|
| [] -> assert false
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ module Static = struct
|
||||||
in
|
in
|
||||||
let* () =
|
let* () =
|
||||||
(* todo: is it "taler-privacy-version" for /policy ? *)
|
(* todo: is it "taler-privacy-version" for /policy ? *)
|
||||||
add ~field:"taler-terms-version" Assets.Config.terms_legal_version
|
add ~field:"taler-terms-version" Assets.terms_legal_version
|
||||||
in
|
in
|
||||||
let* () =
|
let* () =
|
||||||
add ~field:"avail-languages" Headers.avail_languages_header_value
|
add ~field:"avail-languages" Headers.avail_languages_header_value
|
||||||
|
|
@ -116,7 +116,7 @@ let routes =
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
let cfg =
|
let cfg =
|
||||||
let port = 3696 in
|
let port = Config.Exchange.port in
|
||||||
let sockaddr = Unix.(ADDR_INET (inet_addr_loopback, port)) in
|
let sockaddr = Unix.(ADDR_INET (inet_addr_loopback, port)) in
|
||||||
Vif.config sockaddr
|
Vif.config sockaddr
|
||||||
in
|
in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue