feat(utils): add utility to mask API keys

- Introduces a function to mask API keys for improved security
- Masks null or short keys entirely with asterisks
- Partially masks longer keys, retaining the first five characters
This commit is contained in:
2025-05-11 11:16:11 +02:00
parent 73bf48d4d7
commit 79dfbcf053

6
src/utils.ts Normal file
View File

@@ -0,0 +1,6 @@
export const maskApiKey = (key: string | null): string => {
if (!key) return '*****';
return key.length <= 5
? '*'.repeat(key.length)
: key.slice(0, 5) + '*'.repeat(key.length - 5);
};