@clerk/nextjs
Version:
Clerk SDK for NextJS
59 lines • 2.13 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var logFormatter_exports = {};
__export(logFormatter_exports, {
logFormatter: () => logFormatter
});
module.exports = __toCommonJS(logFormatter_exports);
const SENSITIVE_KEYS = /* @__PURE__ */ new Set(["sessionToken", "tokenInHeader", "sessionTokenInCookie", "secretKey", "jwtKey"]);
const maskSecretKey = (str) => {
if (!str || typeof str !== "string") {
return str;
}
try {
return (str || "").replace(/^(sk_(live|test)_)(.+?)(.{3})$/, "$1*********$4");
} catch {
return "";
}
};
const redactSensitive = (value, key) => {
if (key && SENSITIVE_KEYS.has(key) && typeof value === "string") {
return value.substring(0, 7);
}
if (Array.isArray(value)) {
return value.map((item) => redactSensitive(item));
}
if (value && typeof value === "object") {
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, redactSensitive(v, k)]));
}
return maskSecretKey(value);
};
const logFormatter = (entry) => {
return (Array.isArray(entry) ? entry : [entry]).map((entry2) => {
if (typeof entry2 === "string") {
return maskSecretKey(entry2);
}
return JSON.stringify(redactSensitive(entry2), null, 2);
}).join(", ");
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
logFormatter
});
//# sourceMappingURL=logFormatter.js.map