Review fixes

This commit is contained in:
x032205
2025-07-19 01:40:33 -04:00
parent 38b9d1f5a5
commit de2df991d7
2 changed files with 15 additions and 2 deletions

View File

@@ -46,6 +46,9 @@ const createErrorMessage = (error: unknown) => {
return "Unknown error"; return "Unknown error";
}; };
// Delay between each revocation call in revokeCredentials
const DELAY_MS = 1000;
export const oktaClientSecretRotationFactory: TRotationFactory< export const oktaClientSecretRotationFactory: TRotationFactory<
TOktaClientSecretRotationWithConnection, TOktaClientSecretRotationWithConnection,
TOktaClientSecretRotationGeneratedCredentials TOktaClientSecretRotationGeneratedCredentials
@@ -182,6 +185,16 @@ export const oktaClientSecretRotationFactory: TRotationFactory<
} }
}); });
} catch (error: unknown) { } catch (error: unknown) {
if (
error instanceof AxiosError &&
error.response?.data &&
isOktaErrorResponse(error.response.data) &&
error.response.data.errorCode === "E0000001"
) {
// If this is the last secret, we cannot revoke it
return;
}
throw new BadRequestError({ throw new BadRequestError({
message: `Failed to remove client secret with secretId ${secretId} from app ${clientId}: ${createErrorMessage(error)}` message: `Failed to remove client secret with secretId ${secretId} from app ${clientId}: ${createErrorMessage(error)}`
}); });
@@ -209,7 +222,7 @@ export const oktaClientSecretRotationFactory: TRotationFactory<
for (const { secretId } of credentials) { for (const { secretId } of credentials) {
await revokeCredential(secretId); await revokeCredential(secretId);
await delayMs(1000); await delayMs(DELAY_MS);
} }
return callback(); return callback();
}; };

View File

@@ -25,5 +25,5 @@ export type TOktaApp = {
id: string; id: string;
label: string; label: string;
status: "ACTIVE" | "INACTIVE"; status: "ACTIVE" | "INACTIVE";
name: string; // "oidc_client" or other types name: "oidc_client"; // "oidc_client" or other types
}; };