"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataSanitizer = void 0;
const utils_1 = require("./utils.js");
const json_1 = require("../serialization/json.js");
const json_2 = require("../serialization/json.js");
const json_3 = require("../serialization/json.js");
const json_4 = require("../serialization/json.js");
class DataSanitizer {
    constructor(fields) {
        this.keysToSanitize = {
            ['authorization']: '',
            ['access_token']: '',
            ['refresh_token']: '',
            ['subject_token']: '',
            ['token']: '',
            ['client_id']: '',
            ['client_secret']: '',
            ['shared_link']: '',
            ['download_url']: '',
            ['jwt_private_key']: '',
            ['jwt_private_key_passphrase']: '',
            ['password']: '',
        };
    }
    /**
       * @param {{
          readonly [key: string]: string;
      }} headers
       * @returns {{
          readonly [key: string]: string;
      }}
       */
    sanitizeHeaders(headers) {
        return (0, utils_1.sanitizeMap)(headers, this.keysToSanitize);
    }
    /**
     * @param {SerializedData} body
     * @returns {SerializedData}
     */
    sanitizeBody(body) {
        return (0, json_1.sanitizeSerializedData)(body, this.keysToSanitize);
    }
    /**
     * @param {string} body
     * @returns {string}
     */
    sanitizeFormEncodedBody(body) {
        return (0, json_2.sanitizeFormEncodedBodyFromString)(body, this.keysToSanitize);
    }
    /**
     * @param {string} body
     * @param {string} contentType
     * @returns {string}
     */
    sanitizeStringBody(body, contentType) {
        if (contentType == 'application/json' ||
            contentType == 'application/json-patch+json') {
            try {
                return (0, json_4.sdToJson)(this.sanitizeBody((0, json_3.jsonToSerializedData)(body)));
            }
            catch (error) {
                return body;
            }
            finally {
            }
        }
        if (contentType == 'application/x-www-form-urlencoded') {
            return this.sanitizeFormEncodedBody(body);
        }
        return body;
    }
}
exports.DataSanitizer = DataSanitizer;
//# sourceMappingURL=logging.js.map