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:
6
src/utils.ts
Normal file
6
src/utils.ts
Normal 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);
|
||||
};
|
Reference in New Issue
Block a user