"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
var passport_saml_metadata_1 = require("passport-saml-metadata");
var fs = require("fs");
var path = require("path");
var retry = require("async-retry");
var Logger_1 = require("./Logger");
var openflow_api_1 = require("@openiap/openflow-api");
var Config = /** @class */ (function () {
    function Config() {
    }
    Config.getversion = function () {
        var 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;
    };
    Config.reload = function () {
        Config.getversion();
        Config.logpath = Config.getEnv("logpath", __dirname);
        Config.log_queries = Config.parseBoolean(Config.getEnv("log_queries", "false"));
        Config.log_aggregates = Config.parseBoolean(Config.getEnv("log_aggregates", "false"));
        Config.log_inserts = Config.parseBoolean(Config.getEnv("log_inserts", "false"));
        Config.log_updates = Config.parseBoolean(Config.getEnv("log_updates", "false"));
        Config.log_deletes = Config.parseBoolean(Config.getEnv("log_deletes", "false"));
        Config.log_otel_times = Config.parseBoolean(Config.getEnv("log_otel_times", "false"));
        Config.openflow_uniqueid = Config.getEnv("openflow_uniqueid", "");
        Config.getting_started_url = Config.getEnv("getting_started_url", "");
        Config.NODE_ENV = Config.getEnv("NODE_ENV", "development");
        Config.stripe_api_key = Config.getEnv("stripe_api_key", "");
        Config.stripe_api_secret = Config.getEnv("stripe_api_secret", "");
        Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
        Config.ensure_indexes = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));
        Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
        Config.auto_create_domains = Config.parseArray(Config.getEnv("auto_create_domains", ""));
        Config.allow_user_registration = Config.parseBoolean(Config.getEnv("allow_user_registration", "false"));
        Config.persist_user_impersonation = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true"));
        Config.allow_personal_nodered = Config.parseBoolean(Config.getEnv("allow_personal_nodered", "false"));
        Config.auto_create_personal_nodered_group = Config.parseBoolean(Config.getEnv("auto_create_personal_nodered_group", "false"));
        Config.force_add_admins = Config.parseBoolean(Config.getEnv("force_add_admins", "true"));
        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.api_credential_cache_seconds = parseInt(Config.getEnv("api_credential_cache_seconds", "60000"));
        Config.api_credential_cache_seconds = parseInt(Config.getEnv("api_credential_cache_seconds", "60000"));
        Config.oauth_token_cache_seconds = parseInt(Config.getEnv("oauth_token_cache_seconds", "60000"));
        Config.oauth_access_token_lifetime = parseInt(Config.getEnv("oauth_access_token_lifetime", "604800"));
        Config.oauth_refresh_token_lifetime = parseInt(Config.getEnv("oauth_refresh_token_lifetime", "604800"));
        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", "600"));
        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.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", "false"));
        Config.multi_tenant = Config.parseBoolean(Config.getEnv("multi_tenant", "false"));
        Config.api_bypass_perm_check = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false"));
        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", "true"));
        Config.amqp_force_exchange_prefix = Config.parseBoolean(Config.getEnv("amqp_force_exchange_prefix", "true"));
        Config.amqp_url = Config.getEnv("amqp_url", "amqp://localhost"); // used to register queues and by personal nodered
        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.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.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_image = Config.getEnv("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.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.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_trace_url = Config.getEnv("otel_trace_url", "");
        Config.otel_metric_url = Config.getEnv("otel_metric_url", "");
        Config.otel_servicename = Config.getEnv("otel_servicename", "openflow");
        Config.otel_trace_interval = parseInt(Config.getEnv("otel_trace_interval", "5000"));
        Config.otel_metric_interval = parseInt(Config.getEnv("otel_metric_interval", "5000"));
        Config.validate_user_form = Config.getEnv("validate_user_form", "");
    };
    Config.baseurl = function () {
        var 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) {
            result = result + ":" + Config.port + "/";
        }
        else {
            result = result + "/";
        }
        return result;
    };
    Config.basewsurl = function () {
        var 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) {
            result = result + ":" + Config.port + "/";
        }
        else {
            result = result + "/";
        }
        return result;
    };
    Config.getEnv = function (name, defaultvalue) {
        var value = process.env[name];
        if (!value || value === "") {
            value = defaultvalue;
        }
        return value;
    };
    Config.parse_federation_metadata = function (url) {
        return __awaiter(this, void 0, void 0, function () {
            var metadata;
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, retry(function (bail) { return __awaiter(_this, void 0, void 0, function () {
                            var reader, config;
                            return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0: return [4 /*yield*/, passport_saml_metadata_1.fetch({ url: url })];
                                    case 1:
                                        reader = _a.sent();
                                        if (openflow_api_1.NoderedUtil.IsNullUndefinded(reader)) {
                                            bail(new Error("Failed getting result"));
                                            return [2 /*return*/];
                                        }
                                        config = passport_saml_metadata_1.toPassportConfig(reader);
                                        // we need this, for Office 365 :-/
                                        if (reader.signingCerts && reader.signingCerts.length > 1) {
                                            config.cert = reader.signingCerts;
                                        }
                                        return [2 /*return*/, config];
                                }
                            });
                        }); }, {
                            retries: 50,
                            onRetry: function (error, count) {
                                Logger_1.Logger.instanse.warn("retry " + count + " error " + error.message + " getting " + url);
                            }
                        })];
                    case 1:
                        metadata = _a.sent();
                        return [2 /*return*/, metadata];
                }
            });
        });
    };
    Config.parseArray = function (s) {
        var arr = s.split(",");
        arr = arr.map(function (p) { return p.trim(); });
        arr = arr.filter(function (result) { return (result.trim() !== ""); });
        return arr;
    };
    Config.parseBoolean = function (s) {
        var val = "false";
        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);
        }
    };
    Config.db = null;
    Config.license_key = Config.getEnv("license_key", "");
    Config.version = Config.getversion();
    Config.logpath = Config.getEnv("logpath", __dirname);
    Config.log_queries = Config.parseBoolean(Config.getEnv("log_queries", "false"));
    Config.log_aggregates = Config.parseBoolean(Config.getEnv("log_aggregates", "false"));
    Config.log_inserts = Config.parseBoolean(Config.getEnv("log_inserts", "false"));
    Config.log_updates = Config.parseBoolean(Config.getEnv("log_updates", "false"));
    Config.log_deletes = Config.parseBoolean(Config.getEnv("log_deletes", "false"));
    Config.log_otel_times = Config.parseBoolean(Config.getEnv("log_otel_times", "false"));
    Config.openflow_uniqueid = Config.getEnv("openflow_uniqueid", "");
    Config.getting_started_url = Config.getEnv("getting_started_url", "");
    Config.NODE_ENV = Config.getEnv("NODE_ENV", "development");
    Config.stripe_api_key = Config.getEnv("stripe_api_key", "");
    Config.stripe_api_secret = Config.getEnv("stripe_api_secret", "");
    Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
    Config.ensure_indexes = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));
    Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
    Config.auto_create_domains = Config.parseArray(Config.getEnv("auto_create_domains", ""));
    Config.allow_user_registration = Config.parseBoolean(Config.getEnv("allow_user_registration", "false"));
    Config.persist_user_impersonation = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true"));
    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", "true"));
    Config.auto_create_personal_nodered_group = Config.parseBoolean(Config.getEnv("auto_create_personal_nodered_group", "false"));
    Config.force_add_admins = Config.parseBoolean(Config.getEnv("force_add_admins", "true"));
    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.api_credential_cache_seconds = parseInt(Config.getEnv("api_credential_cache_seconds", "60000"));
    Config.dashboard_credential_cache_seconds = parseInt(Config.getEnv("dashboard_credential_cache_seconds", "60000"));
    Config.grafana_credential_cache_seconds = parseInt(Config.getEnv("grafana_credential_cache_seconds", "60000"));
    Config.cleanacl_credential_cache_seconds = parseInt(Config.getEnv("grafana_credential_cache_seconds", "60000"));
    Config.oauth_token_cache_seconds = parseInt(Config.getEnv("oauth_token_cache_seconds", "60000"));
    Config.oauth_access_token_lifetime = parseInt(Config.getEnv("oauth_access_token_lifetime", "604800"));
    Config.oauth_refresh_token_lifetime = parseInt(Config.getEnv("oauth_refresh_token_lifetime", "604800"));
    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", "600"));
    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.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.roles_cached_in_seconds = parseInt(Config.getEnv("roles_cached_in_seconds", "300"));
    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", "false"));
    Config.multi_tenant = Config.parseBoolean(Config.getEnv("multi_tenant", "false"));
    Config.api_bypass_perm_check = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false"));
    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.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", "true"));
    Config.amqp_force_exchange_prefix = Config.parseBoolean(Config.getEnv("amqp_force_exchange_prefix", "true"));
    Config.amqp_url = Config.getEnv("amqp_url", "amqp://localhost"); // used to register queues and by personal nodered
    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.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.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_image = Config.getEnv("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.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 = Config.getEnv("nodered_liveness_failurethreshold", "5"); // 1000m = 1vCPU
    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_trace_url = Config.getEnv("otel_trace_url", "");
    Config.otel_metric_url = Config.getEnv("otel_metric_url", "");
    Config.otel_servicename = Config.getEnv("otel_servicename", "openflow");
    Config.otel_trace_interval = parseInt(Config.getEnv("otel_trace_interval", "5000"));
    Config.otel_metric_interval = parseInt(Config.getEnv("otel_metric_interval", "5000"));
    Config.validate_user_form = Config.getEnv("validate_user_form", "");
    return Config;
}());
exports.Config = Config;
//# sourceMappingURL=Config.js.map