"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NoderedImage = exports.Config = exports.dbConfig = void 0;
const passport_saml_metadata_1 = require("passport-saml-metadata");
const fs = require("fs");
const path = require("path");
const Logger_1 = require("./Logger");
const openflow_api_1 = require("@openiap/openflow-api");
const Logger_2 = require("./Logger");
class dbConfig extends openflow_api_1.Base {
    constructor() {
        super();
        this._type = "config";
        this.name = "Base configuration";
        this.version = "0.0.1";
    }
    async Save(jwt, parent) {
        if (this.needsupdate = true) {
            this.updatedat = new Date(new Date().toISOString());
            this.needsupdate = false;
            this.version = Config.version;
        }
        openflow_api_1.Base.addRight(this, openflow_api_1.WellknownIds.admins, "admins", [openflow_api_1.Rights.full_control]);
        if (openflow_api_1.NoderedUtil.IsNullEmpty(this._id))
            await Config.db.InsertOne(this, "config", 1, true, jwt, parent);
        if (!openflow_api_1.NoderedUtil.IsNullEmpty(this._id))
            await Config.db._UpdateOne(null, this, "config", 1, true, jwt, parent);
    }
    compare(version) {
        return this.version.localeCompare(version, undefined, { numeric: true, sensitivity: 'base' });
    }
    static async Load(jwt, parent) {
        var conf = await Config.db.GetOne({ query: { "_type": "config" }, collectionname: "config", jwt }, parent);
        if (conf == null) {
            conf = new dbConfig();
        }
        conf = Object.assign(new dbConfig(), conf);
        conf.needsupdate = false;
        if (conf.compare(Config.version) == -1) {
            conf.needsupdate = true;
        }
        Config.log_with_trace = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_with_trace) ? conf.log_with_trace : Config.getEnv("log_with_trace", "false"));
        if (!openflow_api_1.NoderedUtil.IsNullEmpty(conf.auto_create_users))
            Config.auto_create_users = Config.parseBoolean(conf.auto_create_users);
        if (!openflow_api_1.NoderedUtil.IsNullEmpty(conf.allow_personal_nodered))
            Config.allow_personal_nodered = Config.parseBoolean(conf.allow_personal_nodered);
        if (!openflow_api_1.NoderedUtil.IsNullEmpty(conf.amqp_enabled_exchange))
            Config.amqp_enabled_exchange = Config.parseBoolean(conf.amqp_enabled_exchange);
        Logger_1.Logger.instanse.info("db version: " + conf.version, parent);
        Config.log_with_trace = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_with_trace) ? conf.log_with_trace : Config.getEnv("log_with_trace", "false"));
        Config.log_with_colors = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_with_colors) ? conf.log_with_colors : Config.getEnv("log_with_colors", "true"));
        Config.log_cache = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_cache) ? conf.log_cache : Config.getEnv("log_cache", "false"));
        Config.log_amqp = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_amqp) ? conf.log_amqp : Config.getEnv("log_amqp", "false"));
        Config.log_login_provider = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_login_provider) ? conf.log_login_provider : Config.getEnv("log_login_provider", "false"));
        Config.log_websocket = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_websocket) ? conf.log_websocket : Config.getEnv("log_websocket", "false"));
        Config.log_oauth = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_oauth) ? conf.log_oauth : Config.getEnv("log_oauth", "false"));
        Config.log_webserver = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_webserver) ? conf.log_webserver : Config.getEnv("log_webserver", "false"));
        Config.log_database = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_database) ? conf.log_database : Config.getEnv("log_database", "false"));
        Config.log_database_queries = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_database_queries) ? conf.log_database_queries : Config.getEnv("log_database_queries", "false"));
        Config.log_database_queries_ms = parseInt(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_database_queries_ms) ? conf.log_database_queries_ms.toString() : Config.getEnv("log_database_queries_ms", "0"));
        Config.log_grafana = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_grafana) ? conf.log_grafana : Config.getEnv("log_grafana", "false"));
        Config.log_housekeeping = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_housekeeping) ? conf.log_housekeeping : Config.getEnv("log_housekeeping", "false"));
        Config.log_otel = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_otel) ? conf.log_otel : Config.getEnv("log_otel", "false"));
        Config.log_blocked_ips = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_blocked_ips) ? conf.log_blocked_ips : Config.getEnv("log_blocked_ips", "true"));
        Config.otel_debug_log = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_debug_log) ? conf.otel_debug_log : Config.getEnv("otel_debug_log", "false"));
        Config.otel_warn_log = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_warn_log) ? conf.otel_warn_log : Config.getEnv("otel_warn_log", "false"));
        Config.otel_err_log = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_err_log) ? conf.otel_err_log : Config.getEnv("otel_err_log", "false"));
        Config.log_information = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_information) ? conf.log_information : Config.getEnv("log_information", "true"));
        Config.log_debug = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_debug) ? conf.log_debug : Config.getEnv("log_debug", "false"));
        Config.log_verbose = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_verbose) ? conf.log_verbose : Config.getEnv("log_verbose", "false"));
        Config.log_silly = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_silly) ? conf.log_silly : Config.getEnv("log_silly", "false"));
        Config.log_to_exchange = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.log_to_exchange) ? conf.log_to_exchange : Config.getEnv("log_to_exchange", "false"));
        Config.client_heartbeat_timeout = parseInt(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.client_heartbeat_timeout) ? conf.client_heartbeat_timeout.toString() : Config.getEnv("client_heartbeat_timeout", "60"));
        Config.client_signin_timeout = parseInt(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.client_signin_timeout) ? conf.client_signin_timeout.toString() : Config.getEnv("client_signin_timeout", "120"));
        Config.client_disconnect_signin_error = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.client_disconnect_signin_error) ? conf.client_disconnect_signin_error : Config.getEnv("client_disconnect_signin_error", "false"));
        Config.api_bypass_perm_check = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.api_bypass_perm_check) ? conf.api_bypass_perm_check : Config.getEnv("api_bypass_perm_check", "false"));
        Config.workitem_queue_monitoring_interval = parseInt(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.workitem_queue_monitoring_interval) ? conf.workitem_queue_monitoring_interval.toString() : Config.getEnv("workitem_queue_monitoring_interval", "10000"));
        Config.workitem_queue_monitoring_enabled = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.workitem_queue_monitoring_enabled) ? conf.workitem_queue_monitoring_enabled : Config.getEnv("workitem_queue_monitoring_enabled", "true"));
        Config.amqp_allow_replyto_empty_queuename = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.amqp_allow_replyto_empty_queuename) ? conf.amqp_allow_replyto_empty_queuename : Config.getEnv("amqp_allow_replyto_empty_queuename", "false"));
        Config.enable_web_tours = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.enable_web_tours) ? conf.enable_web_tours : Config.getEnv("enable_web_tours", "true"));
        Config.enable_nodered_tours = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.enable_nodered_tours) ? conf.enable_nodered_tours : Config.getEnv("enable_nodered_tours", "true"));
        Config.housekeeping_skip_collections = !openflow_api_1.NoderedUtil.IsNullEmpty(conf.housekeeping_skip_collections) ? conf.housekeeping_skip_collections : Config.getEnv("housekeeping_skip_collections", "");
        Config.ensure_indexes = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.ensure_indexes) ? conf.ensure_indexes : Config.getEnv("ensure_indexes", "true"));
        // @ts-ignore
        Config.text_index_name_fields = Config.parseArray(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.text_index_name_fields) ? conf.text_index_name_fields : Config.getEnv("text_index_name_fields", "name,_names"));
        Config.auto_create_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.auto_create_users) ? conf.auto_create_users : Config.getEnv("auto_create_users", "false"));
        Config.auto_create_user_from_jwt = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.auto_create_user_from_jwt) ? conf.auto_create_user_from_jwt : Config.getEnv("auto_create_user_from_jwt", ""));
        Config.auto_create_user_from_jwt = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.auto_create_user_from_jwt) ? conf.auto_create_user_from_jwt : Config.getEnv("auto_create_user_from_jwt", ""));
        // @ts-ignore
        Config.auto_create_domains = Config.parseArray(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.auto_create_domains) ? conf.auto_create_domains : Config.getEnv("auto_create_domains", ""));
        Config.persist_user_impersonation = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.persist_user_impersonation) ? conf.persist_user_impersonation : Config.getEnv("persist_user_impersonation", "true"));
        // @ts-ignore
        Config.ping_clients_interval = parseInt(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.ping_clients_interval) ? conf.ping_clients_interval : Config.getEnv("ping_clients_interval", (10000).toString()));
        Config.otel_trace_pingclients = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.ping_clients_interval) ? conf.ping_clients_interval : Config.getEnv("otel_trace_pingclients", "false"));
        Config.otel_trace_dashboardauth = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_dashboardauth) ? conf.otel_trace_dashboardauth : Config.getEnv("otel_trace_dashboardauth", "false"));
        Config.otel_trace_include_query = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_include_query) ? conf.otel_trace_include_query : Config.getEnv("otel_trace_include_query", "false"));
        Config.otel_trace_connection_ips = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_connection_ips) ? conf.otel_trace_connection_ips : Config.getEnv("otel_trace_connection_ips", "false"));
        Config.otel_trace_mongodb_per_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_per_users) ? conf.otel_trace_mongodb_per_users : Config.getEnv("otel_trace_mongodb_per_users", "false"));
        Config.otel_trace_mongodb_query_per_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_query_per_users) ? conf.otel_trace_mongodb_query_per_users : Config.getEnv("otel_trace_mongodb_query_per_users", "false"));
        Config.otel_trace_mongodb_count_per_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_count_per_users) ? conf.otel_trace_mongodb_count_per_users : Config.getEnv("otel_trace_mongodb_query_per_users", "false"));
        Config.otel_trace_mongodb_aggregate_per_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_aggregate_per_users) ? conf.otel_trace_mongodb_aggregate_per_users : Config.getEnv("otel_trace_mongodb_aggregate_per_users", "false"));
        Config.otel_trace_mongodb_insert_per_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_insert_per_users) ? conf.otel_trace_mongodb_insert_per_users : Config.getEnv("otel_trace_mongodb_insert_per_users", "false"));
        Config.otel_trace_mongodb_update_per_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_update_per_users) ? conf.otel_trace_mongodb_update_per_users : Config.getEnv("otel_trace_mongodb_update_per_users", "false"));
        Config.otel_trace_mongodb_delete_per_users = Config.parseBoolean(!openflow_api_1.NoderedUtil.IsNullEmpty(conf.otel_trace_mongodb_delete_per_users) ? conf.otel_trace_mongodb_delete_per_users : Config.getEnv("otel_trace_mongodb_delete_per_users", "false"));
        Logger_1.Logger.reload();
        return conf;
    }
    static async Reload(jwt, parent) {
        Config.dbConfig = await dbConfig.Load(jwt, parent);
    }
}
exports.dbConfig = dbConfig;
class Config {
    static getversion() {
        let versionfile = path.join(__dirname, "VERSION");
        if (!fs.existsSync(versionfile))
            versionfile = path.join(__dirname, "..", "VERSION");
        if (!fs.existsSync(versionfile))
            versionfile = path.join(__dirname, "..", "..", "VERSION");
        if (!fs.existsSync(versionfile))
            versionfile = path.join(__dirname, "..", "..", "..", "VERSION");
        Config.version = (fs.existsSync(versionfile) ? fs.readFileSync(versionfile, "utf8") : "0.0.1");
        return Config.version;
    }
    static disablelogging() {
        Config.log_cache = false;
        Config.log_amqp = false;
        Config.log_login_provider = false;
        Config.log_websocket = false;
        Config.log_oauth = false;
        Config.unittesting = true;
    }
    static reload() {
        Config.getversion();
        Config.logpath = Config.getEnv("logpath", __dirname);
        Config.log_with_colors = Config.parseBoolean(Config.getEnv("log_with_colors", "true"));
        Config.log_with_trace = Config.parseBoolean(Config.getEnv("log_with_trace", "false"));
        Config.log_cache = Config.parseBoolean(Config.getEnv("log_cache", "false"));
        Config.log_amqp = Config.parseBoolean(Config.getEnv("log_amqp", "false"));
        Config.log_login_provider = Config.parseBoolean(Config.getEnv("log_login_provider", "false"));
        Config.log_websocket = Config.parseBoolean(Config.getEnv("log_websocket", "false"));
        Config.log_oauth = Config.parseBoolean(Config.getEnv("log_oauth", "false"));
        Config.log_webserver = Config.parseBoolean(Config.getEnv("log_webserver", "false"));
        Config.log_database = Config.parseBoolean(Config.getEnv("log_database", "false"));
        Config.log_database_queries = Config.parseBoolean(Config.getEnv("log_database_queries", "false"));
        Config.log_database_queries_ms = parseInt(Config.getEnv("log_database_queries_ms", "0"));
        Config.log_grafana = Config.parseBoolean(Config.getEnv("log_grafana", "false"));
        Config.log_housekeeping = Config.parseBoolean(Config.getEnv("log_housekeeping", "false"));
        Config.log_otel = Config.parseBoolean(Config.getEnv("log_otel", "false"));
        Config.log_blocked_ips = Config.parseBoolean(Config.getEnv("log_blocked_ips", "true"));
        Config.log_information = Config.parseBoolean(Config.getEnv("log_information", "true"));
        Config.log_debug = Config.parseBoolean(Config.getEnv("log_debug", "false"));
        Config.log_verbose = Config.parseBoolean(Config.getEnv("log_verbose", "false"));
        Config.log_silly = Config.parseBoolean(Config.getEnv("log_silly", "false"));
        Config.log_to_exchange = Config.parseBoolean(Config.getEnv("log_to_exchange", "false"));
        Config.amqp_allow_replyto_empty_queuename = Config.parseBoolean(Config.getEnv("amqp_allow_replyto_empty_queuename", "false"));
        Config.openflow_uniqueid = Config.getEnv("openflow_uniqueid", "");
        Config.enable_openflow_amqp = Config.parseBoolean(Config.getEnv("enable_openflow_amqp", "false"));
        Config.openflow_amqp_expiration = parseInt(Config.getEnv("openflow_amqp_expiration", (60 * 1000 * 25).toString())); // 25 min
        Config.amqp_prefetch = parseInt(Config.getEnv("amqp_prefetch", "50"));
        Config.enable_entity_restriction = Config.parseBoolean(Config.getEnv("enable_entity_restriction", "false"));
        Config.enable_web_tours = Config.parseBoolean(Config.getEnv("enable_web_tours", "true"));
        Config.enable_nodered_tours = Config.parseBoolean(Config.getEnv("enable_nodered_tours", "true"));
        Config.auto_hourly_housekeeping = Config.parseBoolean(Config.getEnv("auto_hourly_housekeeping", "true"));
        Config.housekeeping_update_usage_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usage_hourly", "false"));
        Config.housekeeping_update_usersize_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usersize_hourly", "true"));
        Config.housekeeping_skip_collections = Config.getEnv("housekeeping_skip_collections", "");
        Config.workitem_queue_monitoring_enabled = Config.parseBoolean(Config.getEnv("workitem_queue_monitoring_enabled", "true"));
        Config.workitem_queue_monitoring_interval = parseInt(Config.getEnv("workitem_queue_monitoring_interval", (10 * 1000).toString())); // 10 sec
        Config.getting_started_url = Config.getEnv("getting_started_url", "");
        Config.NODE_ENV = Config.getEnv("NODE_ENV", "development");
        Config.HTTP_PROXY = Config.getEnv("HTTP_PROXY", "");
        Config.HTTPS_PROXY = Config.getEnv("HTTPS_PROXY", "");
        Config.NO_PROXY = Config.getEnv("NO_PROXY", "");
        Config.stripe_api_key = Config.getEnv("stripe_api_key", "");
        Config.stripe_api_secret = Config.getEnv("stripe_api_secret", "");
        Config.stripe_force_vat = Config.parseBoolean(Config.getEnv("stripe_force_vat", "false"));
        Config.stripe_force_checkout = Config.parseBoolean(Config.getEnv("stripe_force_checkout", "true"));
        Config.stripe_allow_promotion_codes = Config.parseBoolean(Config.getEnv("stripe_allow_promotion_codes", "true"));
        Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
        Config.ensure_indexes = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));
        Config.text_index_name_fields = Config.parseArray(Config.getEnv("text_index_name_fields", "name,_names"));
        Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
        Config.auto_create_user_from_jwt = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false"));
        Config.auto_create_domains = Config.parseArray(Config.getEnv("auto_create_domains", ""));
        Config.persist_user_impersonation = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true"));
        Config.ping_clients_interval = parseInt(Config.getEnv("ping_clients_interval", (10000).toString())); // 12 seconds
        Config.allow_personal_nodered = Config.parseBoolean(Config.getEnv("allow_personal_nodered", "false"));
        Config.use_ingress_beta1_syntax = Config.parseBoolean(Config.getEnv("use_ingress_beta1_syntax", "false"));
        Config.auto_create_personal_nodered_group = Config.parseBoolean(Config.getEnv("auto_create_personal_nodered_group", "false"));
        Config.auto_create_personal_noderedapi_group = Config.parseBoolean(Config.getEnv("auto_create_personal_noderedapi_group", "false"));
        Config.force_add_admins = Config.parseBoolean(Config.getEnv("force_add_admins", "true"));
        Config.validate_emails = Config.parseBoolean(Config.getEnv("validate_emails", "false"));
        Config.forgot_pass_emails = Config.parseBoolean(Config.getEnv("forgot_pass_emails", "false"));
        Config.smtp_service = Config.getEnv("smtp_service", "");
        Config.smtp_from = Config.getEnv("smtp_from", "");
        Config.smtp_user = Config.getEnv("smtp_user", "");
        Config.smtp_pass = Config.getEnv("smtp_service", "");
        Config.smtp_url = Config.getEnv("smtp_url", "");
        Config.debounce_lookup = Config.parseBoolean(Config.getEnv("debounce_lookup", "false"));
        Config.validate_emails_disposable = Config.parseBoolean(Config.getEnv("validate_emails_disposable", "false"));
        Config.tls_crt = Config.getEnv("tls_crt", "");
        Config.tls_key = Config.getEnv("tls_key", "");
        Config.tls_ca = Config.getEnv("tls_ca", "");
        Config.tls_passphrase = Config.getEnv("tls_passphrase", "");
        Config.cache_store_type = Config.getEnv("cache_store_type", "memory");
        Config.cache_store_max = parseInt(Config.getEnv("cache_store_max", "1000"));
        Config.cache_store_ttl_seconds = parseInt(Config.getEnv("cache_store_ttl_seconds", "3600"));
        Config.cache_store_redis_host = Config.getEnv("cache_store_redis_host", "");
        Config.cache_store_redis_port = parseInt(Config.getEnv("cache_store_redis_port", "6379"));
        Config.cache_store_redis_password = Config.getEnv("cache_store_redis_password", "");
        Config.oidc_access_token_ttl = parseInt(Config.getEnv("oidc_access_token_ttl", "480"));
        Config.oidc_authorization_code_ttl = parseInt(Config.getEnv("oidc_authorization_code_ttl", "480"));
        Config.oidc_client_credentials_ttl = parseInt(Config.getEnv("oidc_client_credentials_ttl", "480"));
        Config.oidc_refresh_token_ttl = parseInt(Config.getEnv("oidc_refresh_token_ttl", "20160"));
        Config.oidc_session_ttl = parseInt(Config.getEnv("oidc_session_ttl", "20160"));
        Config.api_rate_limit = Config.parseBoolean(Config.getEnv("api_rate_limit", "true"));
        Config.api_rate_limit_points = parseInt(Config.getEnv("api_rate_limit_points", "60"));
        Config.api_rate_limit_duration = parseInt(Config.getEnv("api_rate_limit_duration", "1"));
        Config.socket_rate_limit = Config.parseBoolean(Config.getEnv("socket_rate_limit", "true"));
        Config.socket_rate_limit_points = parseInt(Config.getEnv("socket_rate_limit_points", "30"));
        Config.socket_rate_limit_points_disconnect = parseInt(Config.getEnv("socket_rate_limit_points_disconnect", "100"));
        Config.socket_rate_limit_duration = parseInt(Config.getEnv("socket_rate_limit_duration", "1"));
        Config.socket_error_rate_limit_points = parseInt(Config.getEnv("socket_error_rate_limit_points", "16"));
        Config.socket_error_rate_limit_duration = parseInt(Config.getEnv("socket_error_rate_limit_duration", "2"));
        Config.client_heartbeat_timeout = parseInt(Config.getEnv("client_heartbeat_timeout", "60"));
        Config.client_signin_timeout = parseInt(Config.getEnv("client_signin_timeout", "120"));
        Config.client_disconnect_signin_error = Config.parseBoolean(Config.getEnv("client_disconnect_signin_error", "false"));
        Config.expected_max_roles = parseInt(Config.getEnv("expected_max_roles", "4000"));
        Config.decorate_roles_fetching_all_roles = Config.parseBoolean(Config.getEnv("decorate_roles_fetching_all_roles", "true"));
        Config.update_acl_based_on_groups = Config.parseBoolean(Config.getEnv("update_acl_based_on_groups", "true"));
        Config.allow_merge_acl = Config.parseBoolean(Config.getEnv("allow_merge_acl", "false"));
        Config.multi_tenant = Config.parseBoolean(Config.getEnv("multi_tenant", "false"));
        Config.cleanup_on_delete_customer = Config.parseBoolean(Config.getEnv("cleanup_on_delete_customer", "false"));
        Config.cleanup_on_delete_user = Config.parseBoolean(Config.getEnv("cleanup_on_delete_user", "false"));
        Config.api_bypass_perm_check = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false"));
        Config.force_audit_ts = Config.parseBoolean(Config.getEnv("force_audit_ts", "false"));
        Config.force_dbusage_ts = Config.parseBoolean(Config.getEnv("force_dbusage_ts", "false"));
        Config.migrate_audit_to_ts = Config.parseBoolean(Config.getEnv("migrate_audit_to_ts", "true"));
        Config.websocket_package_size = parseInt(Config.getEnv("websocket_package_size", "4096"), 10);
        Config.websocket_max_package_count = parseInt(Config.getEnv("websocket_max_package_count", "1024"), 10);
        Config.protocol = Config.getEnv("protocol", "http"); // used by personal nodered and baseurl()
        Config.port = parseInt(Config.getEnv("port", "3000"));
        Config.domain = Config.getEnv("domain", "localhost"); // sent to website and used in baseurl()
        Config.cookie_secret = Config.getEnv("cookie_secret", "NLgUIsozJaxO38ze0WuHthfj2eb1eIEu");
        Config.amqp_reply_expiration = parseInt(Config.getEnv("amqp_reply_expiration", "10000")); // 10 seconds
        Config.amqp_force_queue_prefix = Config.parseBoolean(Config.getEnv("amqp_force_queue_prefix", "false"));
        Config.amqp_force_exchange_prefix = Config.parseBoolean(Config.getEnv("amqp_force_exchange_prefix", "false"));
        Config.amqp_force_sender_has_read = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_read", "true"));
        Config.amqp_force_sender_has_invoke = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_invoke", "false"));
        Config.amqp_force_consumer_has_update = Config.parseBoolean(Config.getEnv("amqp_force_consumer_has_update", "false"));
        Config.amqp_enabled_exchange = Config.parseBoolean(Config.getEnv("amqp_enabled_exchange", "false"));
        Config.amqp_url = Config.getEnv("amqp_url", "amqp://localhost"); // used to register queues and by personal nodered
        Config.amqp_username = Config.getEnv("amqp_username", "guest"); // used to talk wth rabbitmq api, used if not present in amqp_url
        Config.amqp_password = Config.getEnv("amqp_password", "guest"); // used to talk wth rabbitmq api, used if not present in amqp_url
        Config.amqp_check_for_consumer = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer", "true"));
        Config.amqp_check_for_consumer_count = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer_count", "false"));
        Config.amqp_default_expiration = parseInt(Config.getEnv("amqp_default_expiration", "10000")); // 10 seconds
        Config.amqp_requeue_time = parseInt(Config.getEnv("amqp_requeue_time", "1000")); // 1 seconds    
        Config.amqp_dlx = Config.getEnv("amqp_dlx", "openflow-dlx"); // Dead letter exchange, used to pickup dead or timeout messages
        Config.mongodb_url = Config.getEnv("mongodb_url", "mongodb://localhost:27017");
        Config.mongodb_db = Config.getEnv("mongodb_db", "openflow");
        Config.mongodb_minpoolsize = parseInt(Config.getEnv("mongodb_minpoolsize", "25"));
        Config.mongodb_maxpoolsize = parseInt(Config.getEnv("mongodb_maxpoolsize", "25"));
        Config.skip_history_collections = Config.getEnv("skip_history_collections", "");
        Config.history_delta_count = parseInt(Config.getEnv("history_delta_count", "1000"));
        Config.allow_skiphistory = Config.parseBoolean(Config.getEnv("allow_skiphistory", "true"));
        Config.saml_issuer = Config.getEnv("saml_issuer", "the-issuer"); // define uri of STS, also sent to personal nodereds
        Config.aes_secret = Config.getEnv("aes_secret", "");
        Config.signing_crt = Config.getEnv("signing_crt", "");
        Config.singing_key = Config.getEnv("singing_key", "");
        Config.wapid_mail = Config.getEnv("wapid_mail", "");
        Config.wapid_pub = Config.getEnv("wapid_pub", "");
        Config.wapid_key = Config.getEnv("wapid_key", "");
        Config.shorttoken_expires_in = Config.getEnv("shorttoken_expires_in", "5m");
        Config.longtoken_expires_in = Config.getEnv("longtoken_expires_in", "365d");
        Config.downloadtoken_expires_in = Config.getEnv("downloadtoken_expires_in", "15m");
        Config.personalnoderedtoken_expires_in = Config.getEnv("personalnoderedtoken_expires_in", "365d");
        Config.nodered_images = JSON.parse(Config.getEnv("nodered_images", "[{\"name\":\"Latest Plain Nodered\", \"image\":\"openiap/nodered\"}]"));
        Config.saml_federation_metadata = Config.getEnv("saml_federation_metadata", "");
        Config.api_ws_url = Config.getEnv("api_ws_url", "");
        Config.nodered_ws_url = Config.getEnv("nodered_ws_url", "");
        Config.nodered_saml_entrypoint = Config.getEnv("nodered_saml_entrypoint", "");
        Config.nodered_docker_entrypoints = Config.getEnv("nodered_docker_entrypoints", "web");
        Config.nodered_docker_use_project = Config.parseBoolean(Config.getEnv("nodered_docker_use_project", "false"));
        Config.nodered_docker_certresolver = Config.getEnv("nodered_docker_certresolver", "");
        Config.namespace = Config.getEnv("namespace", ""); // also sent to website 
        Config.nodered_domain_schema = Config.getEnv("nodered_domain_schema", ""); // also sent to website
        Config.nodered_initial_liveness_delay = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60"));
        Config.nodered_allow_nodeselector = Config.parseBoolean(Config.getEnv("nodered_allow_nodeselector", "false"));
        Config.nodered_requests_memory = Config.getEnv("nodered_requests_memory", "");
        Config.nodered_requests_cpu = Config.getEnv("nodered_requests_cpu", ""); // 1000m = 1vCPU
        Config.nodered_limits_memory = Config.getEnv("nodered_limits_memory", "");
        Config.nodered_limits_cpu = Config.getEnv("nodered_limits_cpu", ""); // 1000m = 1vCPU
        Config.nodered_liveness_failurethreshold = parseInt(Config.getEnv("nodered_liveness_failurethreshold", "5"));
        Config.nodered_liveness_timeoutseconds = parseInt(Config.getEnv("nodered_liveness_timeoutseconds", "5"));
        Config.noderedcatalogues = Config.getEnv("noderedcatalogues", "");
        Config.prometheus_measure_nodeid = Config.parseBoolean(Config.getEnv("prometheus_measure_nodeid", "false"));
        Config.prometheus_measure_queued_messages = Config.parseBoolean(Config.getEnv("prometheus_measure_queued_messages", "false"));
        Config.prometheus_measure__mongodb_watch = Config.parseBoolean(Config.getEnv("prometheus_measure__mongodb_watch", "false"));
        Config.prometheus_measure_onlineuser = Config.parseBoolean(Config.getEnv("prometheus_measure_onlineuser", "false"));
        Config.enable_analytics = Config.parseBoolean(Config.getEnv("enable_analytics", "true"));
        Config.otel_debug_log = Config.parseBoolean(Config.getEnv("otel_debug_log", "false"));
        Config.otel_warn_log = Config.parseBoolean(Config.getEnv("otel_warn_log", "false"));
        Config.otel_err_log = Config.parseBoolean(Config.getEnv("otel_err_log", "false"));
        Config.otel_trace_url = Config.getEnv("otel_trace_url", "");
        Config.otel_metric_url = Config.getEnv("otel_metric_url", "");
        Config.otel_trace_interval = parseInt(Config.getEnv("otel_trace_interval", "5000"));
        Config.otel_metric_interval = parseInt(Config.getEnv("otel_metric_interval", "5000"));
        Config.otel_trace_pingclients = Config.parseBoolean(Config.getEnv("otel_trace_pingclients", "false"));
        Config.otel_trace_dashboardauth = Config.parseBoolean(Config.getEnv("otel_trace_dashboardauth", "false"));
        Config.otel_trace_include_query = Config.parseBoolean(Config.getEnv("otel_trace_include_query", "false"));
        Config.otel_trace_connection_ips = Config.parseBoolean(Config.getEnv("otel_trace_connection_ips", "false"));
        Config.otel_trace_mongodb_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_per_users", "false"));
        Config.otel_trace_mongodb_query_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_query_per_users", "false"));
        Config.otel_trace_mongodb_count_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_count_per_users", "false"));
        Config.otel_trace_mongodb_aggregate_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_aggregate_per_users", "false"));
        Config.otel_trace_mongodb_insert_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_insert_per_users", "false"));
        Config.otel_trace_mongodb_update_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_update_per_users", "false"));
        Config.otel_trace_mongodb_delete_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_delete_per_users", "false"));
        Config.validate_user_form = Config.getEnv("validate_user_form", "");
    }
    static load_drom_db() {
    }
    static baseurl() {
        let result = "";
        if (Config.tls_crt != '' && Config.tls_key != '') {
            result = "https://" + Config.domain;
        }
        else {
            result = Config.protocol + "://" + Config.domain;
        }
        if (Config.port != 80 && Config.port != 443 && Config.port != 3000) {
            result = result + ":" + Config.port + "/";
        }
        else {
            result = result + "/";
        }
        return result;
    }
    static basewsurl() {
        let result = "";
        if (Config.tls_crt != '' && Config.tls_key != '') {
            result = "wss://" + Config.domain;
        }
        else if (Config.protocol == "http") {
            result = "ws://" + Config.domain;
        }
        else {
            result = "wss://" + Config.domain;
        }
        if (Config.port != 80 && Config.port != 443 && Config.port != 3000) {
            result = result + ":" + Config.port + "/";
        }
        else {
            result = result + "/";
        }
        return result;
    }
    static getEnv(name, defaultvalue) {
        let value = process.env[name];
        if (!value || value === "") {
            value = defaultvalue;
        }
        return value;
    }
    static async parse_federation_metadata(url) {
        // if anything throws, we retry
        return (0, Logger_2.promiseRetry)(async () => {
            const reader = await (0, passport_saml_metadata_1.fetch)({ url });
            if (openflow_api_1.NoderedUtil.IsNullUndefinded(reader)) {
                throw new Error("Failed getting result");
            }
            const config = (0, passport_saml_metadata_1.toPassportConfig)(reader);
            // we need this, for Office 365 :-/
            if (reader.signingCerts && reader.signingCerts.length > 1) {
                config.cert = reader.signingCerts;
            }
            return config;
        }, 10, 1000);
    }
    static parseArray(s) {
        let arr = s.split(",");
        arr = arr.map(p => p.trim());
        arr = arr.filter(result => (result.trim() !== ""));
        return arr;
    }
    static parseBoolean(s) {
        let val;
        if (typeof s === "number") {
            val = s.toString();
        }
        else if (typeof s === "string") {
            val = s.toLowerCase().trim();
        }
        else if (typeof s === "boolean") {
            val = s.toString();
        }
        else {
            throw new Error("Unknown type!");
        }
        switch (val) {
            case "true":
            case "yes":
            case "1": return true;
            case "false":
            case "no":
            case "0":
            case null: return false;
            default: return Boolean(s);
        }
    }
}
exports.Config = Config;
Config.unittesting = false;
Config.db = null;
Config.license_key = Config.getEnv("license_key", "");
Config.version = Config.getversion();
Config.logpath = Config.getEnv("logpath", __dirname);
Config.log_with_colors = Config.parseBoolean(Config.getEnv("log_with_colors", "true"));
Config.log_cache = Config.parseBoolean(Config.getEnv("log_cache", "false"));
Config.log_amqp = Config.parseBoolean(Config.getEnv("log_amqp", "false"));
Config.log_login_provider = Config.parseBoolean(Config.getEnv("log_login_provider", "false"));
Config.log_with_trace = Config.parseBoolean(Config.getEnv("log_with_trace", "false"));
Config.log_websocket = Config.parseBoolean(Config.getEnv("log_websocket", "false"));
Config.log_oauth = Config.parseBoolean(Config.getEnv("log_oauth", "false"));
Config.log_webserver = Config.parseBoolean(Config.getEnv("log_webserver", "false"));
Config.log_database = Config.parseBoolean(Config.getEnv("log_database", "false"));
Config.log_database_queries = Config.parseBoolean(Config.getEnv("log_database_queries", "false"));
Config.log_database_queries_ms = parseInt(Config.getEnv("log_database_queries_ms", "0"));
Config.log_grafana = Config.parseBoolean(Config.getEnv("log_grafana", "false"));
Config.log_housekeeping = Config.parseBoolean(Config.getEnv("log_housekeeping", "false"));
Config.log_otel = Config.parseBoolean(Config.getEnv("log_otel", "false"));
Config.log_blocked_ips = Config.parseBoolean(Config.getEnv("log_blocked_ips", "true"));
Config.log_information = Config.parseBoolean(Config.getEnv("log_information", "true"));
Config.log_debug = Config.parseBoolean(Config.getEnv("log_debug", "false"));
Config.log_verbose = Config.parseBoolean(Config.getEnv("log_verbose", "false"));
Config.log_silly = Config.parseBoolean(Config.getEnv("log_silly", "false"));
Config.log_to_exchange = Config.parseBoolean(Config.getEnv("log_to_exchange", "false"));
Config.amqp_allow_replyto_empty_queuename = Config.parseBoolean(Config.getEnv("amqp_allow_replyto_empty_queuename", "false"));
Config.openflow_uniqueid = Config.getEnv("openflow_uniqueid", "");
Config.enable_openflow_amqp = Config.parseBoolean(Config.getEnv("enable_openflow_amqp", "false"));
Config.openflow_amqp_expiration = parseInt(Config.getEnv("openflow_amqp_expiration", (60 * 1000 * 25).toString())); // 25 min
Config.amqp_prefetch = parseInt(Config.getEnv("amqp_prefetch", "50"));
Config.enable_entity_restriction = Config.parseBoolean(Config.getEnv("enable_entity_restriction", "false"));
Config.enable_web_tours = Config.parseBoolean(Config.getEnv("enable_web_tours", "true"));
Config.enable_nodered_tours = Config.parseBoolean(Config.getEnv("enable_nodered_tours", "true"));
Config.auto_hourly_housekeeping = Config.parseBoolean(Config.getEnv("auto_hourly_housekeeping", "true"));
Config.housekeeping_update_usage_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usage_hourly", "false"));
Config.housekeeping_update_usersize_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usersize_hourly", "true"));
Config.housekeeping_skip_collections = Config.getEnv("housekeeping_skip_collections", "");
Config.workitem_queue_monitoring_enabled = Config.parseBoolean(Config.getEnv("workitem_queue_monitoring_enabled", "true"));
Config.workitem_queue_monitoring_interval = parseInt(Config.getEnv("workitem_queue_monitoring_interval", (10 * 1000).toString())); // 10 sec
Config.upload_max_filesize_mb = parseInt(Config.getEnv("upload_max_filesize_mb", "25"));
Config.getting_started_url = Config.getEnv("getting_started_url", "");
Config.NODE_ENV = Config.getEnv("NODE_ENV", "development");
Config.HTTP_PROXY = Config.getEnv("HTTP_PROXY", "");
Config.HTTPS_PROXY = Config.getEnv("HTTPS_PROXY", "");
Config.NO_PROXY = Config.getEnv("NO_PROXY", "");
Config.stripe_api_key = Config.getEnv("stripe_api_key", "");
Config.stripe_api_secret = Config.getEnv("stripe_api_secret", "");
Config.stripe_force_vat = Config.parseBoolean(Config.getEnv("stripe_force_vat", "false"));
Config.stripe_force_checkout = Config.parseBoolean(Config.getEnv("stripe_force_checkout", "false"));
Config.stripe_allow_promotion_codes = Config.parseBoolean(Config.getEnv("stripe_allow_promotion_codes", "true"));
Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
Config.ensure_indexes = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));
Config.text_index_name_fields = Config.parseArray(Config.getEnv("text_index_name_fields", "name,_names"));
Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
Config.auto_create_user_from_jwt = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false"));
Config.auto_create_domains = Config.parseArray(Config.getEnv("auto_create_domains", ""));
Config.persist_user_impersonation = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true"));
Config.ping_clients_interval = parseInt(Config.getEnv("ping_clients_interval", (10000).toString())); // 12 seconds
Config.allow_personal_nodered = Config.parseBoolean(Config.getEnv("allow_personal_nodered", "false"));
Config.use_ingress_beta1_syntax = Config.parseBoolean(Config.getEnv("use_ingress_beta1_syntax", "false"));
Config.auto_create_personal_nodered_group = Config.parseBoolean(Config.getEnv("auto_create_personal_nodered_group", "false"));
Config.auto_create_personal_noderedapi_group = Config.parseBoolean(Config.getEnv("auto_create_personal_noderedapi_group", "false"));
Config.force_add_admins = Config.parseBoolean(Config.getEnv("force_add_admins", "true"));
Config.validate_emails = Config.parseBoolean(Config.getEnv("validate_emails", "false"));
Config.forgot_pass_emails = Config.parseBoolean(Config.getEnv("forgot_pass_emails", "false"));
Config.smtp_service = Config.getEnv("smtp_service", "");
Config.smtp_from = Config.getEnv("smtp_from", "");
Config.smtp_user = Config.getEnv("smtp_user", "");
Config.smtp_pass = Config.getEnv("smtp_pass", "");
Config.smtp_url = Config.getEnv("smtp_url", "");
Config.debounce_lookup = Config.parseBoolean(Config.getEnv("debounce_lookup", "false"));
Config.validate_emails_disposable = Config.parseBoolean(Config.getEnv("validate_emails_disposable", "false"));
Config.tls_crt = Config.getEnv("tls_crt", "");
Config.tls_key = Config.getEnv("tls_key", "");
Config.tls_ca = Config.getEnv("tls_ca", "");
Config.tls_passphrase = Config.getEnv("tls_passphrase", "");
Config.cache_store_type = Config.getEnv("cache_store_type", "memory");
Config.cache_store_max = parseInt(Config.getEnv("cache_store_max", "1000"));
Config.cache_store_ttl_seconds = parseInt(Config.getEnv("cache_store_ttl_seconds", "3600"));
Config.cache_store_redis_host = Config.getEnv("cache_store_redis_host", "");
Config.cache_store_redis_port = parseInt(Config.getEnv("cache_store_redis_port", "6379"));
Config.cache_store_redis_password = Config.getEnv("cache_store_redis_password", "");
Config.oidc_access_token_ttl = parseInt(Config.getEnv("oidc_access_token_ttl", "480")); // 8 hours
Config.oidc_authorization_code_ttl = parseInt(Config.getEnv("oidc_authorization_code_ttl", "480")); // 8 hours
Config.oidc_client_credentials_ttl = parseInt(Config.getEnv("oidc_client_credentials_ttl", "480")); // 8 hours
Config.oidc_refresh_token_ttl = parseInt(Config.getEnv("oidc_refresh_token_ttl", "20160")); // 14 days in seconds
Config.oidc_session_ttl = parseInt(Config.getEnv("oidc_session_ttl", "20160")); // 14 days in seconds
Config.oidc_cookie_key = Config.getEnv("oidc_cookie_key", "Y6SPiXCxDhAJbN7cbydMw5eX1wIrdy8PiWApqEcguss=");
Config.api_rate_limit = Config.parseBoolean(Config.getEnv("api_rate_limit", "true"));
Config.api_rate_limit_points = parseInt(Config.getEnv("api_rate_limit_points", "20"));
Config.api_rate_limit_duration = parseInt(Config.getEnv("api_rate_limit_duration", "1"));
Config.socket_rate_limit = Config.parseBoolean(Config.getEnv("socket_rate_limit", "true"));
Config.socket_rate_limit_points = parseInt(Config.getEnv("socket_rate_limit_points", "30"));
Config.socket_rate_limit_points_disconnect = parseInt(Config.getEnv("socket_rate_limit_points_disconnect", "100"));
Config.socket_rate_limit_duration = parseInt(Config.getEnv("socket_rate_limit_duration", "1"));
Config.socket_error_rate_limit_points = parseInt(Config.getEnv("socket_error_rate_limit_points", "30"));
Config.socket_error_rate_limit_duration = parseInt(Config.getEnv("socket_error_rate_limit_duration", "1"));
Config.client_heartbeat_timeout = parseInt(Config.getEnv("client_heartbeat_timeout", "60"));
Config.client_signin_timeout = parseInt(Config.getEnv("client_signin_timeout", "120"));
Config.client_disconnect_signin_error = Config.parseBoolean(Config.getEnv("client_disconnect_signin_error", "false"));
Config.expected_max_roles = parseInt(Config.getEnv("expected_max_roles", "20000"));
Config.decorate_roles_fetching_all_roles = Config.parseBoolean(Config.getEnv("decorate_roles_fetching_all_roles", "true"));
Config.max_recursive_group_depth = parseInt(Config.getEnv("max_recursive_group_depth", "2"));
Config.update_acl_based_on_groups = Config.parseBoolean(Config.getEnv("update_acl_based_on_groups", "true"));
Config.allow_merge_acl = Config.parseBoolean(Config.getEnv("allow_merge_acl", "false"));
Config.multi_tenant = Config.parseBoolean(Config.getEnv("multi_tenant", "false"));
Config.cleanup_on_delete_customer = Config.parseBoolean(Config.getEnv("cleanup_on_delete_customer", "false"));
Config.cleanup_on_delete_user = Config.parseBoolean(Config.getEnv("cleanup_on_delete_user", "false"));
Config.api_bypass_perm_check = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false"));
Config.force_audit_ts = Config.parseBoolean(Config.getEnv("force_audit_ts", "false"));
Config.force_dbusage_ts = Config.parseBoolean(Config.getEnv("force_dbusage_ts", "false"));
Config.migrate_audit_to_ts = Config.parseBoolean(Config.getEnv("migrate_audit_to_ts", "true"));
Config.websocket_package_size = parseInt(Config.getEnv("websocket_package_size", "4096"), 10);
Config.websocket_max_package_count = parseInt(Config.getEnv("websocket_max_package_count", "1024"), 10);
Config.websocket_disconnect_out_of_sync = Config.parseBoolean(Config.getEnv("websocket_disconnect_out_of_sync", "false"));
Config.protocol = Config.getEnv("protocol", "http"); // used by personal nodered and baseurl()
Config.port = parseInt(Config.getEnv("port", "3000"));
Config.domain = Config.getEnv("domain", "localhost"); // sent to website and used in baseurl()
Config.cookie_secret = Config.getEnv("cookie_secret", "NLgUIsozJaxO38ze0WuHthfj2eb1eIEu"); // Used to protect cookies
Config.max_ace_count = parseInt(Config.getEnv("max_ace_count", "128"), 10);
Config.amqp_reply_expiration = parseInt(Config.getEnv("amqp_reply_expiration", (60 * 1000).toString())); // 1 min
Config.amqp_force_queue_prefix = Config.parseBoolean(Config.getEnv("amqp_force_queue_prefix", "false"));
Config.amqp_force_exchange_prefix = Config.parseBoolean(Config.getEnv("amqp_force_exchange_prefix", "false"));
Config.amqp_force_sender_has_read = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_read", "true"));
Config.amqp_force_sender_has_invoke = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_invoke", "false"));
Config.amqp_force_consumer_has_update = Config.parseBoolean(Config.getEnv("amqp_force_consumer_has_update", "false"));
Config.amqp_enabled_exchange = Config.parseBoolean(Config.getEnv("amqp_enabled_exchange", "false"));
Config.amqp_url = Config.getEnv("amqp_url", "amqp://localhost"); // used to register queues and by personal nodered
Config.amqp_username = Config.getEnv("amqp_username", "guest"); // used to talk wth rabbitmq api
Config.amqp_password = Config.getEnv("amqp_password", "guest"); // used to talk wth rabbitmq api
Config.amqp_check_for_consumer = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer", "true"));
Config.amqp_check_for_consumer_count = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer_count", "false"));
Config.amqp_default_expiration = parseInt(Config.getEnv("amqp_default_expiration", (60 * 1000).toString())); // 1 min
Config.amqp_requeue_time = parseInt(Config.getEnv("amqp_requeue_time", "1000")); // 1 seconds    
Config.amqp_dlx = Config.getEnv("amqp_dlx", "openflow-dlx"); // Dead letter exchange, used to pickup dead or timeout messages
Config.mongodb_url = Config.getEnv("mongodb_url", "mongodb://localhost:27017");
Config.mongodb_db = Config.getEnv("mongodb_db", "openflow");
Config.mongodb_minpoolsize = parseInt(Config.getEnv("mongodb_minpoolsize", "25"));
Config.mongodb_maxpoolsize = parseInt(Config.getEnv("mongodb_maxpoolsize", "25"));
Config.skip_history_collections = Config.getEnv("skip_history_collections", "");
Config.history_delta_count = parseInt(Config.getEnv("history_delta_count", "1000"));
Config.allow_skiphistory = Config.parseBoolean(Config.getEnv("allow_skiphistory", "true"));
Config.saml_issuer = Config.getEnv("saml_issuer", "the-issuer"); // define uri of STS, also sent to personal nodereds
Config.aes_secret = Config.getEnv("aes_secret", "");
Config.signing_crt = Config.getEnv("signing_crt", "");
Config.singing_key = Config.getEnv("singing_key", "");
Config.wapid_mail = Config.getEnv("wapid_mail", "");
Config.wapid_pub = Config.getEnv("wapid_pub", "");
Config.wapid_key = Config.getEnv("wapid_key", "");
Config.shorttoken_expires_in = Config.getEnv("shorttoken_expires_in", "5m");
Config.longtoken_expires_in = Config.getEnv("longtoken_expires_in", "365d");
Config.downloadtoken_expires_in = Config.getEnv("downloadtoken_expires_in", "15m");
Config.personalnoderedtoken_expires_in = Config.getEnv("personalnoderedtoken_expires_in", "365d");
// public static nodered_image: string = Config.getEnv("nodered_image", "openiap/nodered");
Config.nodered_images = JSON.parse(Config.getEnv("nodered_images", "[{\"name\":\"Latest Plain Nodered\", \"image\":\"openiap/nodered\"}]"));
Config.saml_federation_metadata = Config.getEnv("saml_federation_metadata", "");
Config.api_ws_url = Config.getEnv("api_ws_url", "");
Config.nodered_ws_url = Config.getEnv("nodered_ws_url", "");
Config.nodered_saml_entrypoint = Config.getEnv("nodered_saml_entrypoint", "");
Config.nodered_docker_entrypoints = Config.getEnv("nodered_docker_entrypoints", "web");
Config.nodered_docker_use_project = Config.parseBoolean(Config.getEnv("nodered_docker_use_project", "false"));
Config.nodered_docker_certresolver = Config.getEnv("nodered_docker_certresolver", "");
Config.namespace = Config.getEnv("namespace", ""); // also sent to website 
Config.nodered_domain_schema = Config.getEnv("nodered_domain_schema", ""); // also sent to website
Config.nodered_initial_liveness_delay = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60"));
Config.nodered_allow_nodeselector = Config.parseBoolean(Config.getEnv("nodered_allow_nodeselector", "false"));
Config.nodered_requests_memory = Config.getEnv("nodered_requests_memory", "");
Config.nodered_requests_cpu = Config.getEnv("nodered_requests_cpu", ""); // 1000m = 1vCPU
Config.nodered_limits_memory = Config.getEnv("nodered_limits_memory", "");
Config.nodered_limits_cpu = Config.getEnv("nodered_limits_cpu", ""); // 1000m = 1vCPU
Config.nodered_liveness_failurethreshold = parseInt(Config.getEnv("nodered_liveness_failurethreshold", "5"));
Config.nodered_liveness_timeoutseconds = parseInt(Config.getEnv("nodered_liveness_timeoutseconds", "5"));
Config.noderedcatalogues = Config.getEnv("noderedcatalogues", "");
Config.prometheus_measure_nodeid = Config.parseBoolean(Config.getEnv("prometheus_measure_nodeid", "false"));
Config.prometheus_measure_queued_messages = Config.parseBoolean(Config.getEnv("prometheus_measure_queued_messages", "false"));
Config.prometheus_measure__mongodb_watch = Config.parseBoolean(Config.getEnv("prometheus_measure__mongodb_watch", "false"));
Config.prometheus_measure_onlineuser = Config.parseBoolean(Config.getEnv("prometheus_measure_onlineuser", "false"));
Config.enable_analytics = Config.parseBoolean(Config.getEnv("enable_analytics", "true"));
Config.otel_debug_log = Config.parseBoolean(Config.getEnv("otel_debug_log", "false"));
Config.otel_warn_log = Config.parseBoolean(Config.getEnv("otel_warn_log", "false"));
Config.otel_err_log = Config.parseBoolean(Config.getEnv("otel_err_log", "false"));
Config.otel_trace_url = Config.getEnv("otel_trace_url", "");
Config.otel_metric_url = Config.getEnv("otel_metric_url", "");
Config.otel_trace_interval = parseInt(Config.getEnv("otel_trace_interval", "5000"));
Config.otel_metric_interval = parseInt(Config.getEnv("otel_metric_interval", "5000"));
Config.otel_trace_pingclients = Config.parseBoolean(Config.getEnv("otel_trace_pingclients", "false"));
Config.otel_trace_dashboardauth = Config.parseBoolean(Config.getEnv("otel_trace_dashboardauth", "false"));
Config.otel_trace_include_query = Config.parseBoolean(Config.getEnv("otel_trace_include_query", "false"));
Config.otel_trace_connection_ips = Config.parseBoolean(Config.getEnv("otel_trace_connection_ips", "false"));
Config.otel_trace_mongodb_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_per_users", "false"));
Config.otel_trace_mongodb_query_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_query_per_users", "false"));
Config.otel_trace_mongodb_count_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_count_per_users", "false"));
Config.otel_trace_mongodb_aggregate_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_aggregate_per_users", "false"));
Config.otel_trace_mongodb_insert_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_insert_per_users", "false"));
Config.otel_trace_mongodb_update_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_update_per_users", "false"));
Config.otel_trace_mongodb_delete_per_users = Config.parseBoolean(Config.getEnv("otel_trace_mongodb_delete_per_users", "false"));
Config.validate_user_form = Config.getEnv("validate_user_form", "");
class NoderedImage {
}
exports.NoderedImage = NoderedImage;
//# sourceMappingURL=Config.js.map