refactor(browser): return complete observation evidence

This commit is contained in:
morluto
2026-09-29 13:56:49 +08:00
parent 9d1f88cbe8
commit 0e2738ffb6
69 changed files with 747 additions and 1206 deletions
-24
View File
@@ -9,27 +9,3 @@ export const redactSensitiveText = (value: string): string =>
.replace(SECRET_ASSIGNMENT, (_match, name: string) => `${name}=[REDACTED]`)
.replace(BEARER, "Bearer [REDACTED]")
.replace(JWT, "[REDACTED_JWT]");
/** Return a UTF-8-bounded prefix without splitting a code point. */
export const boundedSensitiveText = (
value: string,
maximumBytes: number,
): {
readonly text: string;
readonly bytes: number;
readonly truncated: boolean;
} => {
const redacted = redactSensitiveText(value);
const total = Buffer.byteLength(redacted);
if (total <= maximumBytes)
return { text: redacted, bytes: total, truncated: false };
let text = "";
let bytes = 0;
for (const character of redacted) {
const size = Buffer.byteLength(character);
if (bytes + size > maximumBytes) break;
text += character;
bytes += size;
}
return { text, bytes, truncated: true };
};