feat(secrets): finalize external secrets runtime and migration hardening

This commit is contained in:
joshavant
2026-02-24 19:34:29 -06:00
committed by Peter Steinberger
parent c5b89fbaea
commit 0e69660c41
22 changed files with 442 additions and 38 deletions

View File

@@ -7,9 +7,11 @@ describe("maskApiKey", () => {
expect(maskApiKey(" ")).toBe("missing");
});
it("returns trimmed value when length is 16 chars or less", () => {
expect(maskApiKey(" abcdefghijklmnop ")).toBe("abcdefghijklmnop");
expect(maskApiKey(" short ")).toBe("short");
it("masks short and medium values without returning raw secrets", () => {
expect(maskApiKey(" abcdefghijklmnop ")).toBe("ab...op");
expect(maskApiKey(" short ")).toBe("s...t");
expect(maskApiKey(" a ")).toBe("a...a");
expect(maskApiKey(" ab ")).toBe("a...b");
});
it("masks long values with first and last 8 chars", () => {

View File

@@ -3,8 +3,11 @@ export const maskApiKey = (value: string): string => {
if (!trimmed) {
return "missing";
}
if (trimmed.length <= 6) {
return `${trimmed.slice(0, 1)}...${trimmed.slice(-1)}`;
}
if (trimmed.length <= 16) {
return trimmed;
return `${trimmed.slice(0, 2)}...${trimmed.slice(-2)}`;
}
return `${trimmed.slice(0, 8)}...${trimmed.slice(-8)}`;
};