Add eslint rule and fix as many issues as possible

This commit is contained in:
Khoa Le
2023-06-19 23:42:04 -04:00
parent e9eacc445d
commit 9d33e4756b
689 changed files with 9446 additions and 21821 deletions
+13 -13
View File
@@ -1,27 +1,27 @@
import express from 'express';
import { body } from 'express-validator';
import { validateRequest } from '../../middleware';
import { authController } from '../../controllers/v3';
import { authLimiter } from '../../helpers/rateLimiter';
import express from "express";
import { body } from "express-validator";
import { validateRequest } from "../../middleware";
import { authController } from "../../controllers/v3";
import { authLimiter } from "../../helpers/rateLimiter";
const router = express.Router();
router.post(
'/login1',
"/login1",
authLimiter,
body('email').isString().trim(),
body('providerAuthToken').isString().trim().optional({nullable: true}),
body('clientPublicKey').isString().trim().notEmpty(),
body("email").isString().trim(),
body("providerAuthToken").isString().trim().optional({nullable: true}),
body("clientPublicKey").isString().trim().notEmpty(),
validateRequest,
authController.login1
);
router.post(
'/login2',
"/login2",
authLimiter,
body('email').isString().trim(),
body('providerAuthToken').isString().trim().optional({nullable: true}),
body('clientProof').isString().trim().notEmpty(),
body("email").isString().trim(),
body("providerAuthToken").isString().trim().optional({nullable: true}),
body("clientProof").isString().trim().notEmpty(),
validateRequest,
authController.login2
);
+4 -4
View File
@@ -1,7 +1,7 @@
import auth from './auth';
import secrets from './secrets';
import workspaces from './workspaces';
import signup from './signup';
import auth from "./auth";
import secrets from "./secrets";
import workspaces from "./workspaces";
import signup from "./signup";
export {
auth,
+16 -16
View File
@@ -8,16 +8,16 @@ import {
import { body, param, query } from "express-validator";
import { secretsController } from "../../controllers/v3";
import {
AUTH_MODE_JWT,
AUTH_MODE_API_KEY,
AUTH_MODE_SERVICE_TOKEN,
AUTH_MODE_SERVICE_ACCOUNT,
ADMIN,
AUTH_MODE_API_KEY,
AUTH_MODE_JWT,
AUTH_MODE_SERVICE_ACCOUNT,
AUTH_MODE_SERVICE_TOKEN,
MEMBER,
PERMISSION_WRITE_SECRETS,
SECRET_SHARED,
SECRET_PERSONAL,
PERMISSION_READ_SECRETS,
PERMISSION_WRITE_SECRETS,
SECRET_PERSONAL,
SECRET_SHARED,
} from "../../variables";
router.get(
@@ -40,7 +40,7 @@ router.get(
locationEnvironment: "query",
requiredPermissions: [PERMISSION_READ_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: true
requireE2EEOff: true,
}),
secretsController.getSecretsRaw
);
@@ -67,7 +67,7 @@ router.get(
locationEnvironment: "query",
requiredPermissions: [PERMISSION_READ_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: true
requireE2EEOff: true,
}),
secretsController.getSecretByNameRaw
);
@@ -95,7 +95,7 @@ router.post(
locationEnvironment: "body",
requiredPermissions: [PERMISSION_WRITE_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: true
requireE2EEOff: true,
}),
secretsController.createSecretRaw
);
@@ -123,7 +123,7 @@ router.patch(
locationEnvironment: "body",
requiredPermissions: [PERMISSION_WRITE_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: true
requireE2EEOff: true,
}),
secretsController.updateSecretByNameRaw
);
@@ -150,7 +150,7 @@ router.delete(
locationEnvironment: "body",
requiredPermissions: [PERMISSION_WRITE_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: true
requireE2EEOff: true,
}),
secretsController.deleteSecretByNameRaw
);
@@ -175,7 +175,7 @@ router.get(
locationEnvironment: "query",
requiredPermissions: [PERMISSION_READ_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: false
requireE2EEOff: false,
}),
secretsController.getSecrets
);
@@ -210,7 +210,7 @@ router.post(
locationEnvironment: "body",
requiredPermissions: [PERMISSION_WRITE_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: false
requireE2EEOff: false,
}),
secretsController.createSecret
);
@@ -266,7 +266,7 @@ router.patch(
locationEnvironment: "body",
requiredPermissions: [PERMISSION_WRITE_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: false
requireE2EEOff: false,
}),
secretsController.updateSecretByName
);
@@ -293,7 +293,7 @@ router.delete(
locationEnvironment: "body",
requiredPermissions: [PERMISSION_WRITE_SECRETS],
requireBlindIndicesEnabled: true,
requireE2EEOff: false
requireE2EEOff: false,
}),
secretsController.deleteSecretByName
);
+20 -20
View File
@@ -1,27 +1,27 @@
import express from 'express';
import express from "express";
const router = express.Router();
import { body } from 'express-validator';
import { signupController } from '../../controllers/v3';
import { authLimiter } from '../../helpers/rateLimiter';
import { validateRequest } from '../../middleware';
import { body } from "express-validator";
import { signupController } from "../../controllers/v3";
import { authLimiter } from "../../helpers/rateLimiter";
import { validateRequest } from "../../middleware";
router.post(
'/complete-account/signup',
"/complete-account/signup",
authLimiter,
body('email').exists().isString().trim().notEmpty().isEmail(),
body('firstName').exists().isString().trim().notEmpty(),
body('lastName').exists().isString().trim().optional({nullable: true}),
body('protectedKey').exists().isString().trim().notEmpty(),
body('protectedKeyIV').exists().isString().trim().notEmpty(),
body('protectedKeyTag').exists().isString().trim().notEmpty(),
body('publicKey').exists().isString().trim().notEmpty(),
body('encryptedPrivateKey').exists().isString().trim().notEmpty(),
body('encryptedPrivateKeyIV').exists().isString().trim().notEmpty(),
body('encryptedPrivateKeyTag').exists().isString().trim().notEmpty(),
body('salt').exists().isString().trim().notEmpty(),
body('verifier').exists().isString().trim().notEmpty(),
body('organizationName').exists().isString().trim().notEmpty(),
body('providerAuthToken').isString().trim().optional({nullable: true}),
body("email").exists().isString().trim().notEmpty().isEmail(),
body("firstName").exists().isString().trim().notEmpty(),
body("lastName").exists().isString().trim().optional({nullable: true}),
body("protectedKey").exists().isString().trim().notEmpty(),
body("protectedKeyIV").exists().isString().trim().notEmpty(),
body("protectedKeyTag").exists().isString().trim().notEmpty(),
body("publicKey").exists().isString().trim().notEmpty(),
body("encryptedPrivateKey").exists().isString().trim().notEmpty(),
body("encryptedPrivateKeyIV").exists().isString().trim().notEmpty(),
body("encryptedPrivateKeyTag").exists().isString().trim().notEmpty(),
body("salt").exists().isString().trim().notEmpty(),
body("verifier").exists().isString().trim().notEmpty(),
body("organizationName").exists().isString().trim().notEmpty(),
body("providerAuthToken").isString().trim().optional({nullable: true}),
validateRequest,
signupController.completeAccountSignup,
);
+26 -26
View File
@@ -1,75 +1,75 @@
import express from 'express';
import express from "express";
const router = express.Router();
import {
requireAuth,
requireWorkspaceAuth,
validateRequest
} from '../../middleware';
import { workspacesController } from '../../controllers/v3';
validateRequest,
} from "../../middleware";
import { workspacesController } from "../../controllers/v3";
import {
ADMIN,
AUTH_MODE_JWT,
ADMIN
} from '../../variables';
import { param, body } from 'express-validator';
} from "../../variables";
import { body, param } from "express-validator";
// -- migration to blind indices endpoints
router.get(
'/:workspaceId/secrets/blind-index-status',
param('workspaceId').exists().isString().trim(),
"/:workspaceId/secrets/blind-index-status",
param("workspaceId").exists().isString().trim(),
validateRequest,
requireAuth({
acceptedAuthModes: [AUTH_MODE_JWT]
acceptedAuthModes: [AUTH_MODE_JWT],
}),
requireWorkspaceAuth({
acceptedRoles: [ADMIN],
locationWorkspaceId: 'params',
locationWorkspaceId: "params",
}),
workspacesController.getWorkspaceBlindIndexStatus
);
router.get( // allow admins to get all workspace secrets (part of blind indices migration)
'/:workspaceId/secrets',
param('workspaceId').exists().isString().trim(),
"/:workspaceId/secrets",
param("workspaceId").exists().isString().trim(),
validateRequest,
requireAuth({
acceptedAuthModes: [AUTH_MODE_JWT]
acceptedAuthModes: [AUTH_MODE_JWT],
}),
requireWorkspaceAuth({
acceptedRoles: [ADMIN],
locationWorkspaceId: 'params',
locationWorkspaceId: "params",
}),
workspacesController.getWorkspaceSecrets
);
router.post( // allow admins to name all workspace secrets (part of blind indices migration)
'/:workspaceId/secrets/names',
param('workspaceId').exists().isString().trim(),
body('secretsToUpdate')
"/:workspaceId/secrets/names",
param("workspaceId").exists().isString().trim(),
body("secretsToUpdate")
.exists()
.isArray()
.withMessage('secretsToUpdate must be an array')
.withMessage("secretsToUpdate must be an array")
.customSanitizer((value) => {
return value.map((secret: any) => ({
secretName: secret.secretName,
_id: secret._id
_id: secret._id,
}));
}),
body('secretsToUpdate.*.secretName')
body("secretsToUpdate.*.secretName")
.exists()
.isString()
.withMessage('secretName must be a string'),
body('secretsToUpdate.*._id')
.withMessage("secretName must be a string"),
body("secretsToUpdate.*._id")
.exists()
.isString()
.withMessage('secretId must be a string'),
.withMessage("secretId must be a string"),
validateRequest,
requireAuth({
acceptedAuthModes: [AUTH_MODE_JWT]
acceptedAuthModes: [AUTH_MODE_JWT],
}),
requireWorkspaceAuth({
acceptedRoles: [ADMIN],
locationWorkspaceId: 'params'
locationWorkspaceId: "params",
}),
workspacesController.nameWorkspaceSecrets
);