From 9ac83fa3b2698651d7a489f54363a4243d7f9338 Mon Sep 17 00:00:00 2001 From: swrup Date: Mon, 13 Oct 2025 03:16:45 +0200 Subject: [PATCH] rename --- src/assets.ml | 17 ++-- src/config.ml | 187 ++++---------------------------------------- src/config_mte.ml | 19 ----- src/headers.ml | 6 +- src/mte.ml | 2 +- src/taler_config.ml | 174 +++++++++++++++++++++++++++++++++++++++++ src/util.ml | 2 +- 7 files changed, 203 insertions(+), 204 deletions(-) delete mode 100644 src/config_mte.ml create mode 100644 src/taler_config.ml diff --git a/src/assets.ml b/src/assets.ml index cf1ed97b..4ec1b634 100644 --- a/src/assets.ml +++ b/src/assets.ml @@ -13,16 +13,16 @@ type t = | Privacy let etag = function - | Terms -> Config_mte.terms_etag - | Privacy -> Config_mte.privacy_etag + | Terms -> Config.terms_etag + | Privacy -> Config.privacy_etag let legal_version = function - | Terms -> Config_mte.terms_legal_version - | Privacy -> Config_mte.privacy_legal_version + | Terms -> Config.terms_legal_version + | Privacy -> Config.privacy_legal_version let base_dir = function - | Terms -> Config_mte.terms_dir - | Privacy -> Config_mte.privacy_dir + | Terms -> Config.terms_dir + | Privacy -> Config.privacy_dir (* TODO better use of Fmt to have error prefix or smthing @@ -55,9 +55,8 @@ let supported_lang_arr, supported_ext_arr = let () = 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 not @@ List.mem Config_mte.default_lang lang_l then - Fmt.failwith "default language `%s` files not found" - Config_mte.default_lang; + if not @@ List.mem Config.default_lang lang_l then + Fmt.failwith "default language `%s` files not found" Config.default_lang; if not @@ List.mem ".txt" ext_l then Fmt.failwith "plain text file not found"; if not @@ List.mem ".md" ext_l then Fmt.failwith "markdown file not found"; diff --git a/src/config.ml b/src/config.ml index 3374a962..b03e00c7 100644 --- a/src/config.ml +++ b/src/config.ml @@ -1,174 +1,19 @@ -(* https://docs.taler.net/manpages/taler-exchange.conf.5.html - taler-docs/manpages/taler-exchange.conf.5.rst *) -(* TODO - - generate `config.ml` from config file (virtual module)? - - parse config file format - - no relative path - - default config - - better types - - impl duration - *) +(* config_mte.ml + config value that are not in official config options *) -(* TODO unikernel *) -type dir_path -type file_path +let default_lang = "en" +let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity -(* TODO *) -(* Values that represent a time duration are represented as a series of one or more NUMBER UNIT pairs, e.g. 60 s, 4 weeks 1 day, 5 years 2 minutes. *) -type duration +(* TODO Taler documentation markdown mimetype should be the prefered one, and be + supported, according to DD we take text/plain as default instead for now *) +let default_mimetype = ("text", "plain") +let default_extension = ".txt" +let terms_dir = Fpath.(v "terms") +let privacy_dir = Fpath.(v "privacy") -(* TODO - make it Amount.t *) -type amount = string -type payto_uri = string - -(* TODO - still need to parse them and tell that its not supported - some maybe are relevant - idk *) -type not_relevant -type url = string -type seconds = int - -(* not relevant for mirage *) -(* this contains path that can be referenced in other with $PATH - (unsupported) *) -module type Global = sig - val taler_home : dir_path - val taler_data_home : dir_path - val taler_config_home : dir_path - val taler_cache_home : dir_path - val taler_runtime_dir : dir_path -end - -(* sections "[currency-$NAME]" - see DD51 *) -module type Currency = sig - val enabled : [ `YES | `NO ] - val code : string - val name : string - val fractional_input_digits : int - val fractional_normal_digits : int - val fractional_trailing_zero_digits : int - val alt_unit_names : (int * string) list -end - -(* section "[exchange]" *) -module type Exchange = sig - val currency : string - val currency_round_unit : amount - val db : string - val attribute_encryption_key : string - val serve : [ `Unix | `Tcp | `Systemd ] - val unixpath : file_path - val unixpath_mode : int - val port : int - val bind_to : string - val master_public_key : string - val tiny_amount : amount option - val shopping_url : url option - val open_banking_gateway_url : url option - val aml_spa_dialect : string option - val bank_compliance_language : string option - val stefan_abs : amount - val stefan_log : amount - val stefan_lin : float - val base_url : url - val toplevel_redirect_url : string option - val aggregator_idle_sleep_interval : seconds - val closer_idle_sleep_interval : seconds - val transfer_idle_sleep_interval : seconds - val wirewatch_idle_sleep_interval : seconds - val aggregator_shard_size : int option - val signkey_legal_duration : duration - val max_keys_caching : duration - val max_requests : int - val terms_dir : dir_path - val terms_etag : string - val privacy_dir : dir_path - val privacy_etag : string - val enable_kyc : [ `YES | `NO ] -end - -(* section "[taler-exchange-secmod-{rsa|cs|eddsa}]". *) -module type Secmod = sig - val lookahead_sign : duration - val overlap_duration : duration - val sm_priv_key : file_path - val key_dir : dir_path - val unixpath : not_relevant -end - -module type Secmod_rsa = Secmod -module type Secmod_cs = Secmod -module type Secmod_eddsa = Secmod - -(* TODO config - what is the time/duration unit used here? *) -(* section "[exchangedb]". *) -module type Database = sig - val idle_reserve_expiration_time : seconds - val legal_reserve_expiration_time : seconds - val aggregator_shift : seconds - val default_purse_limit : int - val max_aml_program_runtime : int option - - module type Postgres_backend = sig - val config : string - end -end - -(* sections "[coin_XXX]" - used by secmods *) -module type Coin = sig - val value : amount - val duration_withdraw : duration - val duration_spend : duration - val duration_legal : duration - val fee_withdraw : amount - val fee_deposit : amount - val fee_refresh : amount - val fee_refund : amount - val cipher : [ `CS | `RSA ] - val rsa_keysize : int option (*only if `RSA *) - val age_restricted : [ (*`YES|*) `NO ] -end - -(* sections "[exchange-account-XXX]" *) -module type Account = sig - val payto_uri : payto_uri - val enable_debit : [ `YES | `NO ] - val enable_credit : [ `YES | `NO ] -end - -(* sections "[exchange-accountcredentials-XXX]" - must exists for each "[exchange-account-XXX]" section - - ! credentials to access the bank account - should be in a secret configuration file - only redable for `taler-exchange-wirewatch` `taler-exchange-transfer` processes *) -module type Account_secret = sig - val wire_gateway_url : url - val wire_gateway_auth_method : string - val username : string - val password : string - val token : string -end - -(* section "[exchange-extension-]" *) -module type Extensions = sig - val enabled : [ (*`YES|*) `NO ] -end - -(* section "[exchange-offline]". *) -module type Offline_signing = sig - val master_priv_file : file_path - - (* TODO - - we need two different file here - - there is three, not two, crypto helper modules - is it only two, because the eddsa one is not comptabilized as a "crypto helper" here? *) - val secm_tofu_file : file_path - val secm_denom_pubkey : string option - val secm_esign_pubkey : string option -end +(* 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 privacy_legal_version = "1" diff --git a/src/config_mte.ml b/src/config_mte.ml deleted file mode 100644 index b03e00c7..00000000 --- a/src/config_mte.ml +++ /dev/null @@ -1,19 +0,0 @@ -(* config_mte.ml - config value that are not in official config options *) - -let default_lang = "en" -let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity - -(* TODO Taler documentation markdown mimetype should be the prefered one, and be - supported, according to DD we take text/plain as default instead for now *) -let default_mimetype = ("text", "plain") -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 privacy_legal_version = "1" diff --git a/src/headers.ml b/src/headers.ml index 7283a84d..7c6525f0 100644 --- a/src/headers.ml +++ b/src/headers.ml @@ -19,14 +19,14 @@ let select_language headers = |> Cohttp.Accept.qsort |> List.map (fun (_q, lang) -> lang) |> List.map (function - | Cohttp.Accept.AnyLanguage -> Config_mte.default_lang + | Cohttp.Accept.AnyLanguage -> Config.default_lang | Language language_range -> ( (* ignore language subtags (e.g. "en-US" -> "en") *) match language_range with | [] -> assert false | primary_tag :: _ -> primary_tag)) |> List.find_opt Assets.is_supported_lang - |> Option.value ~default:Config_mte.default_lang + |> Option.value ~default:Config.default_lang let select_encoding headers = Vif.Headers.get headers "accept-encoding" @@ -37,7 +37,7 @@ let select_encoding headers = | Cohttp.Accept.Identity -> Some `Identity | Deflate -> Some `DEFLATE | Gzip -> Some `Gzip - | AnyEncoding -> Some Config_mte.default_encoding + | AnyEncoding -> Some Config.default_encoding | Encoding _ | Compress -> (* unsupported *) None) |> function | [] -> assert false diff --git a/src/mte.ml b/src/mte.ml index f94ad473..8c013b47 100644 --- a/src/mte.ml +++ b/src/mte.ml @@ -83,7 +83,7 @@ module Static = struct in let* () = (* todo: is it "taler-privacy-version" for /policy ? *) - add ~field:"taler-terms-version" Config_mte.terms_legal_version + add ~field:"taler-terms-version" Config.terms_legal_version in let* () = add ~field:"avail-languages" Headers.avail_languages_header_value diff --git a/src/taler_config.ml b/src/taler_config.ml new file mode 100644 index 00000000..3374a962 --- /dev/null +++ b/src/taler_config.ml @@ -0,0 +1,174 @@ +(* https://docs.taler.net/manpages/taler-exchange.conf.5.html + taler-docs/manpages/taler-exchange.conf.5.rst *) +(* TODO + - generate `config.ml` from config file (virtual module)? + - parse config file format + - no relative path + - default config + - better types + - impl duration + *) + +(* TODO unikernel *) +type dir_path +type file_path + +(* TODO *) +(* Values that represent a time duration are represented as a series of one or more NUMBER UNIT pairs, e.g. 60 s, 4 weeks 1 day, 5 years 2 minutes. *) +type duration + +(* TODO + make it Amount.t *) +type amount = string +type payto_uri = string + +(* TODO + still need to parse them and tell that its not supported + some maybe are relevant + idk *) +type not_relevant +type url = string +type seconds = int + +(* not relevant for mirage *) +(* this contains path that can be referenced in other with $PATH + (unsupported) *) +module type Global = sig + val taler_home : dir_path + val taler_data_home : dir_path + val taler_config_home : dir_path + val taler_cache_home : dir_path + val taler_runtime_dir : dir_path +end + +(* sections "[currency-$NAME]" + see DD51 *) +module type Currency = sig + val enabled : [ `YES | `NO ] + val code : string + val name : string + val fractional_input_digits : int + val fractional_normal_digits : int + val fractional_trailing_zero_digits : int + val alt_unit_names : (int * string) list +end + +(* section "[exchange]" *) +module type Exchange = sig + val currency : string + val currency_round_unit : amount + val db : string + val attribute_encryption_key : string + val serve : [ `Unix | `Tcp | `Systemd ] + val unixpath : file_path + val unixpath_mode : int + val port : int + val bind_to : string + val master_public_key : string + val tiny_amount : amount option + val shopping_url : url option + val open_banking_gateway_url : url option + val aml_spa_dialect : string option + val bank_compliance_language : string option + val stefan_abs : amount + val stefan_log : amount + val stefan_lin : float + val base_url : url + val toplevel_redirect_url : string option + val aggregator_idle_sleep_interval : seconds + val closer_idle_sleep_interval : seconds + val transfer_idle_sleep_interval : seconds + val wirewatch_idle_sleep_interval : seconds + val aggregator_shard_size : int option + val signkey_legal_duration : duration + val max_keys_caching : duration + val max_requests : int + val terms_dir : dir_path + val terms_etag : string + val privacy_dir : dir_path + val privacy_etag : string + val enable_kyc : [ `YES | `NO ] +end + +(* section "[taler-exchange-secmod-{rsa|cs|eddsa}]". *) +module type Secmod = sig + val lookahead_sign : duration + val overlap_duration : duration + val sm_priv_key : file_path + val key_dir : dir_path + val unixpath : not_relevant +end + +module type Secmod_rsa = Secmod +module type Secmod_cs = Secmod +module type Secmod_eddsa = Secmod + +(* TODO config + what is the time/duration unit used here? *) +(* section "[exchangedb]". *) +module type Database = sig + val idle_reserve_expiration_time : seconds + val legal_reserve_expiration_time : seconds + val aggregator_shift : seconds + val default_purse_limit : int + val max_aml_program_runtime : int option + + module type Postgres_backend = sig + val config : string + end +end + +(* sections "[coin_XXX]" + used by secmods *) +module type Coin = sig + val value : amount + val duration_withdraw : duration + val duration_spend : duration + val duration_legal : duration + val fee_withdraw : amount + val fee_deposit : amount + val fee_refresh : amount + val fee_refund : amount + val cipher : [ `CS | `RSA ] + val rsa_keysize : int option (*only if `RSA *) + val age_restricted : [ (*`YES|*) `NO ] +end + +(* sections "[exchange-account-XXX]" *) +module type Account = sig + val payto_uri : payto_uri + val enable_debit : [ `YES | `NO ] + val enable_credit : [ `YES | `NO ] +end + +(* sections "[exchange-accountcredentials-XXX]" + must exists for each "[exchange-account-XXX]" section + + ! credentials to access the bank account + should be in a secret configuration file + only redable for `taler-exchange-wirewatch` `taler-exchange-transfer` processes *) +module type Account_secret = sig + val wire_gateway_url : url + val wire_gateway_auth_method : string + val username : string + val password : string + val token : string +end + +(* section "[exchange-extension-]" *) +module type Extensions = sig + val enabled : [ (*`YES|*) `NO ] +end + +(* section "[exchange-offline]". *) +module type Offline_signing = sig + val master_priv_file : file_path + + (* TODO + - we need two different file here + - there is three, not two, crypto helper modules + is it only two, because the eddsa one is not comptabilized as a "crypto helper" here? *) + val secm_tofu_file : file_path + val secm_denom_pubkey : string option + val secm_esign_pubkey : string option +end diff --git a/src/util.ml b/src/util.ml index 18436a1a..047ffc7e 100644 --- a/src/util.ml +++ b/src/util.ml @@ -24,7 +24,7 @@ module Mimetype = struct List.find_opt (( = ) (m, m_sub)) mimetype_l | AnyMediaSubtype m -> List.find_opt (fun (m', _) -> String.equal m m') mimetype_l - | AnyMedia -> Some Config_mte.default_mimetype + | AnyMedia -> Some Config.default_mimetype let to_extension (m, m_sub) = assert (m <> "*");