Skip to content

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

Fix type error

Carlos Monastyrski59c390ccf185
diff --git a/backend/src/ee/services/certificate-authority-crl/certificate-authority-crl-dal.ts b/backend/src/ee/services/certificate-authority-crl/certificate-authority-crl-dal.ts
index 7524d361ca..3ad69fc62b 100644
--- a/backend/src/ee/services/certificate-authority-crl/certificate-authority-crl-dal.ts
+++ b/backend/src/ee/services/certificate-authority-crl/certificate-authority-crl-dal.ts
@@ -1,10 +1,35 @@
import { TDbClient } from "@app/db";
-import { TableName } from "@app/db/schemas";
+import { TableName, TCertificateAuthorityCrl } from "@app/db/schemas";
+import { DatabaseError } from "@app/lib/errors";
import { ormify, TOrmify } from "@app/lib/knex";
-export type TCertificateAuthorityCrlDALFactory = TOrmify<TableName.CertificateAuthorityCrl>;
+export type TCertificateAuthorityCrlDALFactory = TOrmify<TableName.CertificateAuthorityCrl> & {
+ updateEncryptedCrlAndBumpUpdatedAt: (
+ filter: { caId: string },
+ data: { encryptedCrl: Buffer }
+ ) => Promise<TCertificateAuthorityCrl[]>;
+};
export const certificateAuthorityCrlDALFactory = (db: TDbClient): TCertificateAuthorityCrlDALFactory => {
const caCrlOrm = ormify(db, TableName.CertificateAuthorityCrl);
- return caCrlOrm;
+
+ const updateEncryptedCrlAndBumpUpdatedAt = async (
+ filter: { caId: string },
+ data: { encryptedCrl: Buffer }
+ ): Promise<TCertificateAuthorityCrl[]> => {
+ try {
+ const res = await db(TableName.CertificateAuthorityCrl)
+ .where(filter)
+ .update({ ...data, updatedAt: new Date() } as never)
+ .returning("*");
+ return res as TCertificateAuthorityCrl[];
+ } catch (error) {
+ throw new DatabaseError({ error, name: "UpdateEncryptedCrlAndBumpUpdatedAt" });
+ }
+ };
+
+ return {
+ ...caCrlOrm,
+ updateEncryptedCrlAndBumpUpdatedAt
+ };
};
diff --git a/backend/src/services/certificate-authority/certificate-authority-queue.ts b/backend/src/services/certificate-authority/certificate-authority-queue.ts
index 7995003d30..26343d74fe 100644
--- a/backend/src/services/certificate-authority/certificate-authority-queue.ts
+++ b/backend/src/services/certificate-authority/certificate-authority-queue.ts
@@ -275,7 +275,10 @@ export const certificateAuthorityQueueFactory = ({
plainText: Buffer.from(new Uint8Array(crl.rawData))
});
- await certificateAuthorityCrlDAL.update({ caId: internalCa.caId }, { encryptedCrl, updatedAt: new Date() });
+ await certificateAuthorityCrlDAL.updateEncryptedCrlAndBumpUpdatedAt(
+ { caId: internalCa.caId },
+ { encryptedCrl }
+ );
totalRebuilt += 1;
} catch (err) {
logger.error(err, `${QueueName.CaCrlRotation}: failed to rebuild CRL [caId=${internalCa.caId}]`);