/**
* Convert any Error to a plain Object.
- * @param {String} _key
- * @param {*} value
- * @returns {Object}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {object} value or replaced value
*/
function replacerError(_key, value) {
if (value instanceof Error) {
/**
* Convert any BigInt type to a String.
- * @param {String} _key
- * @param {*} value
- * @returns {String}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {string} value or replaced value
*/
function replacerBigInt(_key, value) {
if (typeof value === 'bigint') {
* Also sanitizes any Authorization header. We do this here rather than
* in sanitization stage so that we do not have to rely on a set path to
* this object.
- * @param {String} _key
- * @param {*} value
- * @returns {Object}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {object} value or replaved value
*/
function replacerHttpIncomingMessage(_key, value) {
if (value instanceof http.IncomingMessage) {
// This blurs entire auth string if no space found, because -1 from indexOf.
const blurredAuthHeader = authHeader.slice(0, spaceIndex + 1) + '*'.repeat(authHeader.length - (spaceIndex + 1));
// New headers object, as we change it.
- newValue.headers = Object.assign({}, newValue.headers, {
+ newValue.headers = {
+ ...newValue.headers,
authorization: blurredAuthHeader,
- });
+ };
}
value = newValue;
}
/**
* Convert any ServerResponse or OutgoingMessage to a subset Object.
- * @param {String} _key
- * @param {*} value
- * @returns {Object}
+ * @param {string} _key key, unused
+ * @param {*} value value to possibly replace
+ * @returns {object} value or replaced value
*/
function replacerHttpServerResponse(_key, value) {
if (value instanceof http.OutgoingMessage || value instanceof http.ServerResponse) {