feat: added token based communications

This commit is contained in:
Akhil Mohan
2024-01-27 12:38:23 +05:30
parent daa94db874
commit 20fb99f042
65 changed files with 699 additions and 360 deletions
+4 -1
View File
@@ -81,7 +81,10 @@ const envSchema = z
SECRET_SCANNING_WEBHOOK_PROXY: zpStr(z.string().optional()),
SECRET_SCANNING_WEBHOOK_SECRET: zpStr(z.string().optional()),
SECRET_SCANNING_GIT_APP_ID: zpStr(z.string().optional()),
SECRET_SCANNING_PRIVATE_KEY: zpStr(z.string().optional())
SECRET_SCANNING_PRIVATE_KEY: zpStr(z.string().optional()),
// LICENCE
LICENCE_SERVER_URL: zpStr(z.string().optional()),
LICENCE_SERVER_KEY: zpStr(z.string().optional())
})
.transform((data) => ({
...data,
+2 -2
View File
@@ -4,9 +4,9 @@ export class DatabaseError extends Error {
error: unknown;
constructor({ name, error, message }: { message?: string; name: string; error: unknown }) {
constructor({ name, error, message }: { message?: string; name?: string; error: unknown }) {
super(message || "Failed to execute db ops");
this.name = name;
this.name = name || "DatabaseError";
this.error = error;
}
}
+6 -5
View File
@@ -103,6 +103,11 @@ export const isValidIpOrCidr = (ip: string): boolean => {
return false;
};
export type TIp = {
ipAddress: string;
type: IPType;
prefix: number;
};
/**
* Validates the IP address [ipAddress] against the trusted IPs [trustedIps].
*/
@@ -111,11 +116,7 @@ export const checkIPAgainstBlocklist = ({
trustedIps
}: {
ipAddress: string;
trustedIps: {
ipAddress: string;
type: IPType;
prefix: number;
}[];
trustedIps: TIp[];
}) => {
const blockList = new net.BlockList();