mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 01:52:22 +00:00
Add eslint rule and fix as many issues as possible
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Types } from "mongoose";
|
||||
import {
|
||||
getSecretsBotHelper,
|
||||
encryptSymmetricHelper,
|
||||
decryptSymmetricHelper,
|
||||
getKey,
|
||||
encryptSymmetricHelper,
|
||||
getIsWorkspaceE2EEHelper,
|
||||
getKey,
|
||||
getSecretsBotHelper,
|
||||
} from "../helpers/bot";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
closeDatabaseHelper,
|
||||
initDatabaseHelper,
|
||||
closeDatabaseHelper
|
||||
} from '../helpers/database';
|
||||
} from "../helpers/database";
|
||||
|
||||
/**
|
||||
* Class to handle database actions
|
||||
@@ -15,7 +15,7 @@ class DatabaseService {
|
||||
*/
|
||||
static async initDatabase(MONGO_URL: string) {
|
||||
return await initDatabaseHelper({
|
||||
mongoURL: MONGO_URL
|
||||
mongoURL: MONGO_URL,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Types } from 'mongoose';
|
||||
import { handleEventHelper } from '../helpers/event';
|
||||
import { Types } from "mongoose";
|
||||
import { handleEventHelper } from "../helpers/event";
|
||||
|
||||
interface Event {
|
||||
name: string;
|
||||
@@ -22,7 +22,7 @@ class EventService {
|
||||
*/
|
||||
static async handleEvent({ event }: { event: Event }): Promise<void> {
|
||||
await handleEventHelper({
|
||||
event
|
||||
event,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Types } from 'mongoose';
|
||||
import { Types } from "mongoose";
|
||||
import {
|
||||
handleOAuthExchangeHelper,
|
||||
syncIntegrationsHelper,
|
||||
getIntegrationAuthRefreshHelper,
|
||||
getIntegrationAuthAccessHelper,
|
||||
setIntegrationAuthRefreshHelper,
|
||||
getIntegrationAuthRefreshHelper,
|
||||
handleOAuthExchangeHelper,
|
||||
setIntegrationAuthAccessHelper,
|
||||
} from '../helpers/integration';
|
||||
setIntegrationAuthRefreshHelper,
|
||||
syncIntegrationsHelper,
|
||||
} from "../helpers/integration";
|
||||
|
||||
/**
|
||||
* Class to handle integrations
|
||||
@@ -30,7 +30,7 @@ class IntegrationService {
|
||||
workspaceId,
|
||||
integration,
|
||||
code,
|
||||
environment
|
||||
environment,
|
||||
}: {
|
||||
workspaceId: string;
|
||||
integration: string;
|
||||
@@ -41,7 +41,7 @@ class IntegrationService {
|
||||
workspaceId,
|
||||
integration,
|
||||
code,
|
||||
environment
|
||||
environment,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ class IntegrationService {
|
||||
*/
|
||||
static async syncIntegrations({
|
||||
workspaceId,
|
||||
environment
|
||||
environment,
|
||||
}: {
|
||||
workspaceId: Types.ObjectId;
|
||||
environment?: string;
|
||||
}) {
|
||||
return await syncIntegrationsHelper({
|
||||
workspaceId
|
||||
workspaceId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class IntegrationService {
|
||||
*/
|
||||
static async getIntegrationAuthRefresh({ integrationAuthId }: { integrationAuthId: Types.ObjectId}) {
|
||||
return await getIntegrationAuthRefreshHelper({
|
||||
integrationAuthId
|
||||
integrationAuthId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class IntegrationService {
|
||||
*/
|
||||
static async getIntegrationAuthAccess({ integrationAuthId }: { integrationAuthId: Types.ObjectId }) {
|
||||
return await getIntegrationAuthAccessHelper({
|
||||
integrationAuthId
|
||||
integrationAuthId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,14 +100,14 @@ class IntegrationService {
|
||||
*/
|
||||
static async setIntegrationAuthRefresh({
|
||||
integrationAuthId,
|
||||
refreshToken
|
||||
refreshToken,
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
refreshToken: string;
|
||||
}) {
|
||||
return await setIntegrationAuthRefreshHelper({
|
||||
integrationAuthId,
|
||||
refreshToken
|
||||
refreshToken,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class IntegrationService {
|
||||
integrationAuthId,
|
||||
accessId,
|
||||
accessToken,
|
||||
accessExpiresAt
|
||||
accessExpiresAt,
|
||||
}: {
|
||||
integrationAuthId: string;
|
||||
accessId: string | null;
|
||||
@@ -137,7 +137,7 @@ class IntegrationService {
|
||||
integrationAuthId,
|
||||
accessId,
|
||||
accessToken,
|
||||
accessExpiresAt
|
||||
accessExpiresAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import { Types } from "mongoose";
|
||||
import {
|
||||
CreateSecretParams,
|
||||
GetSecretsParams,
|
||||
DeleteSecretParams,
|
||||
GetSecretParams,
|
||||
GetSecretsParams,
|
||||
UpdateSecretParams,
|
||||
DeleteSecretParams
|
||||
} from '../interfaces/services/SecretService';
|
||||
} from "../interfaces/services/SecretService";
|
||||
import {
|
||||
createSecretBlindIndexDataHelper,
|
||||
getSecretBlindIndexSaltHelper,
|
||||
generateSecretBlindIndexWithSaltHelper,
|
||||
generateSecretBlindIndexHelper,
|
||||
createSecretHelper,
|
||||
getSecretsHelper,
|
||||
deleteSecretHelper,
|
||||
generateSecretBlindIndexHelper,
|
||||
generateSecretBlindIndexWithSaltHelper,
|
||||
getSecretBlindIndexSaltHelper,
|
||||
getSecretHelper,
|
||||
getSecretsHelper,
|
||||
updateSecretHelper,
|
||||
deleteSecretHelper
|
||||
} from '../helpers/secrets';
|
||||
} from "../helpers/secrets";
|
||||
|
||||
class SecretService {
|
||||
/**
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
import { PostHog } from 'posthog-node';
|
||||
import { getLogger } from '../utils/logger';
|
||||
import { AuthData } from '../interfaces/middleware';
|
||||
import { PostHog } from "posthog-node";
|
||||
import { getLogger } from "../utils/logger";
|
||||
import { AuthData } from "../interfaces/middleware";
|
||||
import {
|
||||
getNodeEnv,
|
||||
getTelemetryEnabled,
|
||||
getPostHogHost,
|
||||
getPostHogProjectApiKey,
|
||||
getPostHogHost
|
||||
} from '../config';
|
||||
getTelemetryEnabled,
|
||||
} from "../config";
|
||||
import {
|
||||
IUser,
|
||||
User,
|
||||
IServiceAccount,
|
||||
ServiceAccount,
|
||||
IServiceTokenData,
|
||||
ServiceTokenData
|
||||
} from '../models';
|
||||
ServiceTokenData,
|
||||
User,
|
||||
} from "../models";
|
||||
import {
|
||||
AccountNotFoundError,
|
||||
BadRequestError
|
||||
} from '../utils/errors';
|
||||
BadRequestError,
|
||||
} from "../utils/errors";
|
||||
|
||||
class Telemetry {
|
||||
/**
|
||||
@@ -31,7 +28,7 @@ class Telemetry {
|
||||
"To improve, Infisical collects telemetry data about general usage.",
|
||||
"This helps us understand how the product is doing and guide our product development to create the best possible platform; it also helps us demonstrate growth as we support Infisical as open-source software.",
|
||||
"To opt into telemetry, you can set `TELEMETRY_ENABLED=true` within the environment variables.",
|
||||
].join('\n'))
|
||||
].join("\n"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +38,10 @@ class Telemetry {
|
||||
*/
|
||||
static getPostHogClient = async () => {
|
||||
let postHogClient: any;
|
||||
if ((await getNodeEnv()) === 'production' && (await getTelemetryEnabled())) {
|
||||
if ((await getNodeEnv()) === "production" && (await getTelemetryEnabled())) {
|
||||
// case: enable opt-out telemetry in production
|
||||
postHogClient = new PostHog(await getPostHogProjectApiKey(), {
|
||||
host: await getPostHogHost()
|
||||
host: await getPostHogHost(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,11 +49,11 @@ class Telemetry {
|
||||
}
|
||||
|
||||
static getDistinctId = async ({
|
||||
authData
|
||||
authData,
|
||||
}: {
|
||||
authData: AuthData;
|
||||
}) => {
|
||||
let distinctId = '';
|
||||
let distinctId = "";
|
||||
if (authData.authPayload instanceof User) {
|
||||
distinctId = authData.authPayload.email;
|
||||
} else if (authData.authPayload instanceof ServiceAccount) {
|
||||
@@ -64,7 +61,7 @@ class Telemetry {
|
||||
} else if (authData.authPayload instanceof ServiceTokenData) {
|
||||
|
||||
if (authData.authPayload.user) {
|
||||
const user = await User.findById(authData.authPayload.user, 'email');
|
||||
const user = await User.findById(authData.authPayload.user, "email");
|
||||
if (!user) throw AccountNotFoundError();
|
||||
distinctId = user.email;
|
||||
} else if (authData.authPayload.serviceAccount) {
|
||||
@@ -72,8 +69,8 @@ class Telemetry {
|
||||
}
|
||||
}
|
||||
|
||||
if (distinctId === '') throw BadRequestError({
|
||||
message: 'Failed to obtain distinct id for logging telemetry'
|
||||
if (distinctId === "") throw BadRequestError({
|
||||
message: "Failed to obtain distinct id for logging telemetry",
|
||||
});
|
||||
|
||||
return distinctId;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Types } from 'mongoose';
|
||||
import { createTokenHelper, validateTokenHelper } from '../helpers/token';
|
||||
import { Types } from "mongoose";
|
||||
import { createTokenHelper, validateTokenHelper } from "../helpers/token";
|
||||
|
||||
/**
|
||||
* Class to handle token actions
|
||||
@@ -19,9 +19,9 @@ class TokenService {
|
||||
type,
|
||||
email,
|
||||
phoneNumber,
|
||||
organizationId
|
||||
organizationId,
|
||||
}: {
|
||||
type: 'emailConfirmation' | 'emailMfa' | 'organizationInvitation' | 'passwordReset';
|
||||
type: "emailConfirmation" | "emailMfa" | "organizationInvitation" | "passwordReset";
|
||||
email?: string;
|
||||
phoneNumber?: string;
|
||||
organizationId?: Types.ObjectId;
|
||||
@@ -30,7 +30,7 @@ class TokenService {
|
||||
type,
|
||||
email,
|
||||
phoneNumber,
|
||||
organizationId
|
||||
organizationId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ class TokenService {
|
||||
email,
|
||||
phoneNumber,
|
||||
organizationId,
|
||||
token
|
||||
token,
|
||||
}: {
|
||||
type: 'emailConfirmation' | 'emailMfa' | 'organizationInvitation' | 'passwordReset';
|
||||
type: "emailConfirmation" | "emailMfa" | "organizationInvitation" | "passwordReset";
|
||||
email?: string;
|
||||
phoneNumber?: string;
|
||||
organizationId?: Types.ObjectId;
|
||||
@@ -61,7 +61,7 @@ class TokenService {
|
||||
email,
|
||||
phoneNumber,
|
||||
organizationId,
|
||||
token
|
||||
token,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import mongoose from 'mongoose';
|
||||
import { createTerminus } from '@godaddy/terminus';
|
||||
import { getLogger } from '../utils/logger';
|
||||
import mongoose from "mongoose";
|
||||
import { createTerminus } from "@godaddy/terminus";
|
||||
import { getLogger } from "../utils/logger";
|
||||
|
||||
export const setUpHealthEndpoint = <T>(server: T) => {
|
||||
const onSignal = async () => {
|
||||
(await getLogger('backend-main')).info('Server is starting clean-up');
|
||||
(await getLogger("backend-main")).info("Server is starting clean-up");
|
||||
return Promise.all([
|
||||
new Promise((resolve) => {
|
||||
if (mongoose.connection && mongoose.connection.readyState == 1) {
|
||||
mongoose.connection.close()
|
||||
.then(() => resolve('Database connection closed'));
|
||||
.then(() => resolve("Database connection closed"));
|
||||
} else {
|
||||
resolve('Database connection already closed');
|
||||
resolve("Database connection already closed");
|
||||
}
|
||||
})
|
||||
}),
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -25,8 +25,8 @@ export const setUpHealthEndpoint = <T>(server: T) => {
|
||||
|
||||
createTerminus(server, {
|
||||
healthChecks: {
|
||||
'/healthcheck': healthCheck,
|
||||
onSignal
|
||||
}
|
||||
"/healthcheck": healthCheck,
|
||||
onSignal,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import DatabaseService from './DatabaseService';
|
||||
import DatabaseService from "./DatabaseService";
|
||||
// import { logTelemetryMessage, getPostHogClient } from './TelemetryService';
|
||||
import TelemetryService from './TelemetryService';
|
||||
import BotService from './BotService';
|
||||
import EventService from './EventService';
|
||||
import IntegrationService from './IntegrationService';
|
||||
import TokenService from './TokenService';
|
||||
import SecretService from './SecretService';
|
||||
import TelemetryService from "./TelemetryService";
|
||||
import BotService from "./BotService";
|
||||
import EventService from "./EventService";
|
||||
import IntegrationService from "./IntegrationService";
|
||||
import TokenService from "./TokenService";
|
||||
import SecretService from "./SecretService";
|
||||
|
||||
export {
|
||||
TelemetryService,
|
||||
@@ -14,5 +14,5 @@ export {
|
||||
EventService,
|
||||
IntegrationService,
|
||||
TokenService,
|
||||
SecretService
|
||||
SecretService,
|
||||
}
|
||||
@@ -1,31 +1,31 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
import nodemailer from "nodemailer";
|
||||
import {
|
||||
SMTP_HOST_SENDGRID,
|
||||
SMTP_HOST_GMAIL,
|
||||
SMTP_HOST_MAILGUN,
|
||||
SMTP_HOST_SENDGRID,
|
||||
SMTP_HOST_SOCKETLABS,
|
||||
SMTP_HOST_ZOHOMAIL,
|
||||
SMTP_HOST_GMAIL
|
||||
} from '../variables';
|
||||
import SMTPConnection from 'nodemailer/lib/smtp-connection';
|
||||
import * as Sentry from '@sentry/node';
|
||||
} from "../variables";
|
||||
import SMTPConnection from "nodemailer/lib/smtp-connection";
|
||||
import * as Sentry from "@sentry/node";
|
||||
import {
|
||||
getSmtpHost,
|
||||
getSmtpUsername,
|
||||
getSmtpPassword,
|
||||
getSmtpPort,
|
||||
getSmtpSecure,
|
||||
getSmtpPort
|
||||
} from '../config';
|
||||
getSmtpUsername,
|
||||
} from "../config";
|
||||
|
||||
export const initSmtp = async () => {
|
||||
const mailOpts: SMTPConnection.Options = {
|
||||
host: await getSmtpHost(),
|
||||
port: await getSmtpPort()
|
||||
port: await getSmtpPort(),
|
||||
};
|
||||
|
||||
if ((await getSmtpUsername()) && (await getSmtpPassword())) {
|
||||
mailOpts.auth = {
|
||||
user: await getSmtpUsername(),
|
||||
pass: await getSmtpPassword()
|
||||
pass: await getSmtpPassword(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,31 +37,31 @@ export const initSmtp = async () => {
|
||||
case SMTP_HOST_MAILGUN:
|
||||
mailOpts.requireTLS = true;
|
||||
mailOpts.tls = {
|
||||
ciphers: 'TLSv1.2'
|
||||
ciphers: "TLSv1.2",
|
||||
}
|
||||
break;
|
||||
case SMTP_HOST_SOCKETLABS:
|
||||
mailOpts.requireTLS = true;
|
||||
mailOpts.tls = {
|
||||
ciphers: 'TLSv1.2'
|
||||
ciphers: "TLSv1.2",
|
||||
}
|
||||
break;
|
||||
case SMTP_HOST_ZOHOMAIL:
|
||||
mailOpts.requireTLS = true;
|
||||
mailOpts.tls = {
|
||||
ciphers: 'TLSv1.2'
|
||||
ciphers: "TLSv1.2",
|
||||
}
|
||||
break;
|
||||
case SMTP_HOST_GMAIL:
|
||||
mailOpts.requireTLS = true;
|
||||
mailOpts.tls = {
|
||||
ciphers: 'TLSv1.2'
|
||||
ciphers: "TLSv1.2",
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ((await getSmtpHost()).includes('amazonaws.com')) {
|
||||
if ((await getSmtpHost()).includes("amazonaws.com")) {
|
||||
mailOpts.tls = {
|
||||
ciphers: 'TLSv1.2'
|
||||
ciphers: "TLSv1.2",
|
||||
}
|
||||
} else {
|
||||
mailOpts.secure = true;
|
||||
@@ -75,7 +75,7 @@ export const initSmtp = async () => {
|
||||
.verify()
|
||||
.then((err) => {
|
||||
Sentry.setUser(null);
|
||||
Sentry.captureMessage('SMTP - Successfully connected');
|
||||
Sentry.captureMessage("SMTP - Successfully connected");
|
||||
console.log("SMTP - Successfully connected")
|
||||
})
|
||||
.catch(async (err) => {
|
||||
|
||||
Reference in New Issue
Block a user