import { sanitizeMap } from './utils.js';
import { sanitizeSerializedData } from '../serialization/json.js';
import { sanitizeFormEncodedBodyFromString } from '../serialization/json.js';
import { jsonToSerializedData } from '../serialization/json.js';
import { sdToJson } from '../serialization/json.js';
export class DataSanitizer {
    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']: '',
    };
    constructor(fields) { }
    /**
       * @param {{
          readonly [key: string]: string;
      }} headers
       * @returns {{
          readonly [key: string]: string;
      }}
       */
    sanitizeHeaders(headers) {
        return sanitizeMap(headers, this.keysToSanitize);
    }
    /**
     * @param {SerializedData} body
     * @returns {SerializedData}
     */
    sanitizeBody(body) {
        return sanitizeSerializedData(body, this.keysToSanitize);
    }
    /**
     * @param {string} body
     * @returns {string}
     */
    sanitizeFormEncodedBody(body) {
        return 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 sdToJson(this.sanitizeBody(jsonToSerializedData(body)));
            }
            catch (error) {
                return body;
            }
            finally {
            }
        }
        if (contentType == 'application/x-www-form-urlencoded') {
            return this.sanitizeFormEncodedBody(body);
        }
        return body;
    }
}
//# sourceMappingURL=logging.js.map