feat: return fastify res and making it async

This commit is contained in:
=
2025-03-21 02:26:33 +05:30
parent 2c40d316f4
commit 905cf47d90
3 changed files with 13 additions and 7 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ export const registerSecretScannerGhApp = async (server: FastifyZodProvider) =>
payload: JSON.stringify(req.body), payload: JSON.stringify(req.body),
signature: signatureSHA256 signature: signatureSHA256
}); });
void res.send("ok"); return res.send("ok");
} }
}); });
} }
+2 -2
View File
@@ -34,7 +34,7 @@ export const registerServeUI = async (
TELEMETRY_CAPTURING_ENABLED: appCfg.TELEMETRY_ENABLED TELEMETRY_CAPTURING_ENABLED: appCfg.TELEMETRY_ENABLED
}; };
const js = `window.__INFISICAL_RUNTIME_ENV__ = Object.freeze(${JSON.stringify(config)});`; const js = `window.__INFISICAL_RUNTIME_ENV__ = Object.freeze(${JSON.stringify(config)});`;
void res.send(js); return res.send(js);
} }
}); });
@@ -57,7 +57,7 @@ export const registerServeUI = async (
reply.callNotFound(); reply.callNotFound();
return; return;
} }
void reply.sendFile("index.html"); return reply.sendFile("index.html");
} }
}); });
} }
@@ -69,9 +69,15 @@ export const identityUaServiceFactory = ({
isClientSecretRevoked: false isClientSecretRevoked: false
}); });
const validClientSecretInfo = clientSecrtInfo.find(({ clientSecretHash }) => let validClientSecretInfo: (typeof clientSecrtInfo)[0] | null = null;
bcrypt.compareSync(clientSecret, clientSecretHash) for await (const info of clientSecrtInfo) {
); const isMatch = await bcrypt.compare(clientSecret, info.clientSecretHash);
if (isMatch) {
validClientSecretInfo = info;
break;
}
}
if (!validClientSecretInfo) throw new UnauthorizedError({ message: "Invalid credentials" }); if (!validClientSecretInfo) throw new UnauthorizedError({ message: "Invalid credentials" });
const { clientSecretTTL, clientSecretNumUses, clientSecretNumUsesLimit } = validClientSecretInfo; const { clientSecretTTL, clientSecretNumUses, clientSecretNumUsesLimit } = validClientSecretInfo;
@@ -104,7 +110,7 @@ export const identityUaServiceFactory = ({
} }
const identityAccessToken = await identityUaDAL.transaction(async (tx) => { const identityAccessToken = await identityUaDAL.transaction(async (tx) => {
const uaClientSecretDoc = await identityUaClientSecretDAL.incrementUsage(validClientSecretInfo.id, tx); const uaClientSecretDoc = await identityUaClientSecretDAL.incrementUsage(validClientSecretInfo!.id, tx);
const newToken = await identityAccessTokenDAL.create( const newToken = await identityAccessTokenDAL.create(
{ {
identityId: identityUa.identityId, identityId: identityUa.identityId,