mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
refactor(pam): update AwsIamAccountForm to use structured submit data
- Changed the onSubmit prop type to accept a structured SubmitData type, enhancing type safety. - Updated the form submission logic to align with the new data structure, ensuring proper handling of form fields.
This commit is contained in:
@@ -30,11 +30,20 @@ import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccou
|
||||
const AWS_STS_MIN_SESSION_DURATION = 900; // 15 minutes
|
||||
const AWS_STS_MAX_SESSION_DURATION_ROLE_CHAINING = 3600; // 1 hour
|
||||
|
||||
type SubmitData = {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
credentials: {
|
||||
targetRoleArn: string;
|
||||
defaultSessionDuration: number;
|
||||
};
|
||||
};
|
||||
|
||||
type Props = {
|
||||
account?: TAwsIamAccount;
|
||||
resourceId?: string;
|
||||
resourceType?: PamResourceType;
|
||||
onSubmit: (formData: FormData) => Promise<void>;
|
||||
onSubmit: (formData: SubmitData) => Promise<void>;
|
||||
};
|
||||
|
||||
const arnRoleRegex = /^arn:aws:iam::\d{12}:role\/[\w+=,.@/-]+$/;
|
||||
@@ -152,12 +161,13 @@ export const AwsIamAccountForm = ({ account, resourceId, resourceType, onSubmit
|
||||
const durationSeconds = Math.floor(durationMs / 1000);
|
||||
|
||||
await onSubmit({
|
||||
...formData,
|
||||
name: formData.name,
|
||||
description: formData.description,
|
||||
credentials: {
|
||||
...formData.credentials,
|
||||
targetRoleArn: formData.credentials.targetRoleArn,
|
||||
defaultSessionDuration: durationSeconds
|
||||
}
|
||||
} as any);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user