Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor(secret-sync): remove type cast in AKV certificate content type filter

Igor Correa0a5415d897ee
diff --git a/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts b/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts
index 1fecde89c7..2554f4c522 100644
--- a/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts
+++ b/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts
@@ -16,7 +16,7 @@ type TAzureKeyVaultSyncFactoryDeps = {
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
};
-const AZURE_KEY_VAULT_CERTIFICATE_CONTENT_TYPES = ["application/x-pkcs12", "application/x-pem-file"] as const;
+const AZURE_KEY_VAULT_CERTIFICATE_CONTENT_TYPES = ["application/x-pkcs12", "application/x-pem-file"];
export const azureKeyVaultSyncFactory = ({ kmsService, appConnectionDAL }: TAzureKeyVaultSyncFactoryDeps) => {
const $getAzureKeyVaultSecrets = async (
@@ -49,10 +49,7 @@ export const azureKeyVaultSyncFactory = ({ kmsService, appConnectionDAL }: TAzur
// filter them out at the list stage if the option is enabled (avoids fetching their values too)
const visibleSecrets = disableCertificateImport
? getAzureKeyVaultSecrets.filter(
- (secret) =>
- !AZURE_KEY_VAULT_CERTIFICATE_CONTENT_TYPES.includes(
- secret.contentType as (typeof AZURE_KEY_VAULT_CERTIFICATE_CONTENT_TYPES)[number]
- )
+ (secret) => !AZURE_KEY_VAULT_CERTIFICATE_CONTENT_TYPES.includes(secret.contentType ?? "")
)
: getAzureKeyVaultSecrets;
diff --git a/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-types.ts b/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-types.ts
index 77c5e5ca97..421b98c7a6 100644
--- a/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-types.ts
+++ b/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-types.ts
@@ -21,7 +21,7 @@ export type TAzureKeyVaultSyncWithCredentials = TAzureKeyVaultSync & {
export interface GetAzureKeyVaultSecret {
id: string; // secret URI
value: string;
- contentType?: string;
+ contentType?: "application/x-pkcs12" | "application/x-pem-file";
attributes: {
enabled: boolean;
created: number;