Merge remote-tracking branch 'origin/main' into pki-revamp

This commit is contained in:
Carlos Monastyrski
2025-10-16 12:33:45 -03:00
211 changed files with 3325 additions and 322 deletions
@@ -2,7 +2,6 @@ import net from "node:net";
import { ForbiddenError } from "@casl/ability";
import * as x509 from "@peculiar/x509";
import { CronJob } from "cron";
import { OrgMembershipRole, TRelays } from "@app/db/schemas";
import { PgSqlLock } from "@app/keystore/keystore";
@@ -891,7 +890,7 @@ export const gatewayV2ServiceFactory = ({
});
};
const $healthcheckNotify = async () => {
const healthcheckNotify = async () => {
const unhealthyGateways = await gatewayV2DAL.find({
isHeartbeatStale: true
});
@@ -945,18 +944,6 @@ export const gatewayV2ServiceFactory = ({
}
};
const initializeHealthcheckNotify = async () => {
logger.info("Setting up background notification process for gateway v2 health-checks");
await $healthcheckNotify();
// run every 5 minutes
const job = new CronJob("*/5 * * * *", $healthcheckNotify);
job.start();
return job;
};
return {
listGateways,
registerGateway,
@@ -965,6 +952,6 @@ export const gatewayV2ServiceFactory = ({
deleteGatewayById,
heartbeat,
getPamSessionKey,
initializeHealthcheckNotify
healthcheckNotify
};
};
+3 -1
View File
@@ -25,7 +25,9 @@ export const initializeHsmModule = (envConfig: Pick<TEnvConfig, "isHsmConfigured
logger.info("PKCS#11 module initialized");
} catch (error) {
if (error instanceof pkcs11js.Pkcs11Error && error.code === pkcs11js.CKR_CRYPTOKI_ALREADY_INITIALIZED) {
logger.error(error, "Failed to initialize PKCS#11 module");
if ((error as { message?: string })?.message === "CKR_CRYPTOKI_ALREADY_INITIALIZED") {
logger.info("Skipping HSM initialization because it's already initialized.");
} else {
logger.error(error, "Failed to initialize PKCS#11 module");
@@ -44,7 +44,7 @@ export const licenseDALFactory = (db: TDbClient) => {
// count org identities
const identityDoc = await (tx || db.replicaNode())(TableName.Membership)
.where({ status: OrgMembershipStatus.Accepted, scope: AccessScope.Organization })
.where({ scope: AccessScope.Organization })
.whereNotNull(`${TableName.Membership}.actorIdentityId`)
.where((bd) => {
if (orgId) {
+2 -15
View File
@@ -2,7 +2,6 @@ import { isIP } from "node:net";
import { ForbiddenError } from "@casl/ability";
import * as x509 from "@peculiar/x509";
import { CronJob } from "cron";
import { OrgMembershipRole, TRelays } from "@app/db/schemas";
import { PgSqlLock } from "@app/keystore/keystore";
@@ -1209,7 +1208,7 @@ export const relayServiceFactory = ({
return deletedRelay;
};
const $healthcheckNotify = async () => {
const healthcheckNotify = async () => {
const unhealthyRelays = await relayDAL.find({
isHeartbeatStale: true
});
@@ -1283,18 +1282,6 @@ export const relayServiceFactory = ({
}
};
const initializeHealthcheckNotify = async () => {
logger.info("Setting up background notification process for relay health-checks");
await $healthcheckNotify();
// run every 5 minutes
const job = new CronJob("*/5 * * * *", $healthcheckNotify);
job.start();
return job;
};
return {
registerRelay,
getCredentialsForGateway,
@@ -1302,6 +1289,6 @@ export const relayServiceFactory = ({
getRelays,
deleteRelay,
heartbeat,
initializeHealthcheckNotify
healthcheckNotify
};
};