Skip to content

Commit 8697e5c

Browse files
authored
fix(secret): obscure secret value entry within tui (#86)
## Description <!-- Provide a brief description of your changes --> **Note:** PR titles should follow [Conventional Commits](https://www.conventionalcommits.org/) format (e.g., `feat(devbox): add support for custom env vars` or `fix(snapshot): resolve pagination issue`) as they are used for automatic release notes generation. ## Type of Change <!-- Mark the relevant option with an 'x' --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test updates ## Related Issues <!-- Link to related issues using #issue-number --> Closes # ## Changes Made <!-- Describe the changes in detail --> ## Testing <!-- Describe how you tested your changes --> - [ ] I have tested locally - [ ] I have added/updated tests - [ ] All existing tests pass ## Checklist - [ ] My code follows the code style of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published ## Screenshots (if applicable) <!-- Add screenshots to help explain your changes --> ## Additional Notes <!-- Any additional information that reviewers should know -->
1 parent 2b36b19 commit 8697e5c

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/components/SecretCreatePage.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,11 @@ export const SecretCreatePage = ({
301301
const value = formData[field.key as keyof FormData] as string;
302302
const hasError =
303303
field.key === "value" && validationError === "Value is required";
304-
// Display masked value when not active
305-
const maskedValue = "*".repeat(value.length);
306304
return (
307305
<FormTextInput
308306
key={field.key}
309307
label={field.label}
310-
value={isActive ? value : maskedValue}
308+
value={value}
311309
onChange={(newValue) => {
312310
setFormData({ ...formData, [field.key]: newValue });
313311
if (validationError) {
@@ -318,6 +316,7 @@ export const SecretCreatePage = ({
318316
isActive={isActive}
319317
placeholder="Enter secret value"
320318
error={hasError ? validationError : undefined}
319+
mask="*"
321320
/>
322321
);
323322
}

src/components/form/FormTextInput.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export interface FormTextInputProps {
1616
error?: string;
1717
/** Called when Enter is pressed in the text input */
1818
onSubmit?: () => void;
19+
/** Character to mask input with (e.g., "*" for passwords) */
20+
mask?: string;
1921
}
2022

2123
export const FormTextInput = ({
@@ -26,7 +28,11 @@ export const FormTextInput = ({
2628
placeholder,
2729
error,
2830
onSubmit,
31+
mask,
2932
}: FormTextInputProps) => {
33+
// Display value: use mask character if provided
34+
const displayValue = mask && value ? mask.repeat(value.length) : value;
35+
3036
return (
3137
<FormField label={label} isActive={isActive} error={error}>
3238
{isActive ? (
@@ -35,10 +41,11 @@ export const FormTextInput = ({
3541
onChange={onChange}
3642
placeholder={placeholder}
3743
onSubmit={onSubmit}
44+
mask={mask}
3845
/>
3946
) : (
4047
<Text color={error ? colors.error : colors.text}>
41-
{value || "(empty)"}
48+
{displayValue || "(empty)"}
4249
</Text>
4350
)}
4451
</FormField>

0 commit comments

Comments
 (0)