@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
53 lines (51 loc) • 1.6 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 1.1.2
* @copyright (c) 2026 Bitrix24
* @license MIT
* @see https://github.com/bitrix24/b24jssdk
* @see https://bitrix24.github.io/b24jssdk/
*/
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
const SENSITIVE_PARAM_KEYS = [
"auth",
"password",
"token",
"secret",
"access_token",
"refresh_token"
];
const REDACTED_PLACEHOLDER = "***REDACTED***";
function isPlainObject(value) {
return value !== null && typeof value === "object" && !Array.isArray(value);
}
__name(isPlainObject, "isPlainObject");
function redactObject(source, depth) {
const sanitized = { ...source };
for (const key of Object.keys(sanitized)) {
if (SENSITIVE_PARAM_KEYS.includes(key)) {
sanitized[key] = REDACTED_PLACEHOLDER;
continue;
}
if (depth <= 0) continue;
const child = sanitized[key];
if (isPlainObject(child)) {
sanitized[key] = redactObject(child, depth - 1);
} else if (Array.isArray(child)) {
sanitized[key] = child.map(
(item) => isPlainObject(item) ? redactObject(item, depth - 1) : item
);
}
}
return sanitized;
}
__name(redactObject, "redactObject");
const DEFAULT_REDACT_DEPTH = 2;
function redactSensitiveParams(params) {
if (!isPlainObject(params)) return params;
return redactObject(params, DEFAULT_REDACT_DEPTH);
}
__name(redactSensitiveParams, "redactSensitiveParams");
export { REDACTED_PLACEHOLDER, SENSITIVE_PARAM_KEYS, redactSensitiveParams };
//# sourceMappingURL=redact.mjs.map