Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

lint:fix

Blue Mouseddc483e5d9b6
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts
index dfa7b4e26..6405180ad 100644
--- a/src/auth/auth.controller.ts
+++ b/src/auth/auth.controller.ts
@@ -451,12 +451,7 @@ export class AuthController {
const ip =
headers['cf-connecting-ip'] || headers['x-forwarded-for'] || reqIP || ''
- await checkRateLimit(
- ip,
- 'sso-generate',
- OAUTH_RATE_LIMIT,
- 1800,
- )
+ await checkRateLimit(ip, 'sso-generate', OAUTH_RATE_LIMIT, 1800)
const { provider } = body
@@ -483,12 +478,7 @@ export class AuthController {
const ip =
headers['cf-connecting-ip'] || headers['x-forwarded-for'] || reqIP || ''
- await checkRateLimit(
- ip,
- 'sso-process',
- OAUTH_RATE_LIMIT,
- 1800,
- )
+ await checkRateLimit(ip, 'sso-process', OAUTH_RATE_LIMIT, 1800)
const { token, hash } = body
diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts
index f162f495f..ed62fef45 100644
--- a/src/auth/auth.service.ts
+++ b/src/auth/auth.service.ts
@@ -39,7 +39,8 @@ import { TelegrafContext } from 'src/user/user.controller'
import { UserService } from 'src/user/user.service'
import { ProjectService } from 'src/project/project.service'
import {
- saveRefreshTokenClickhouse, findRefreshTokenClickhouse,
+ saveRefreshTokenClickhouse,
+ findRefreshTokenClickhouse,
} from 'src/common/utils'
import {
REDIS_SSO_UUID,
@@ -51,10 +52,10 @@ import {
SELFHOSTED_PASSWORD,
SELFHOSTED_UUID,
} from 'src/common/constants'
+import { RefreshToken } from 'src/user/entities/refresh-token.entity'
import { SSOProviders } from './dtos/sso-generate.dto'
import { UserGoogleDTO } from '../user/dto/user-google.dto'
import { UserGithubDTO } from '../user/dto/user-github.dto'
-import { RefreshToken } from 'src/user/entities/refresh-token.entity'
const REDIS_SSO_SESSION_TIMEOUT = 60 * 5 // 5 minutes
const getSSORedisKey = (uuid: string) => `${REDIS_SSO_UUID}:${uuid}`
diff --git a/src/auth/guards/roles.guard.ts b/src/auth/guards/roles.guard.ts
index 2b6c535dd..421c027f7 100644
--- a/src/auth/guards/roles.guard.ts
+++ b/src/auth/guards/roles.guard.ts
@@ -5,8 +5,8 @@ import { verify } from 'jsonwebtoken'
import { UserType, generateSelfhostedUser } from 'src/user/entities/user.entity'
import { UserService } from 'src/user/user.service'
-import { IS_TWO_FA_NOT_REQUIRED_KEY, ROLES_KEY } from '../decorators'
import { isSelfhosted } from 'src/common/constants'
+import { IS_TWO_FA_NOT_REQUIRED_KEY, ROLES_KEY } from '../decorators'
const ACCESS_TOKEN_SECRET = process.env.JWT_ACCESS_TOKEN_SECRET
@@ -60,7 +60,7 @@ export class RolesGuard implements CanActivate {
if (isSelfhosted) {
try {
const decoded: any = verify(token, ACCESS_TOKEN_SECRET)
-
+
// If the token is not decoded, it means it's invalid
if (!decoded) {
return false
diff --git a/src/auth/strategies/jwt-access-token.strategy.ts b/src/auth/strategies/jwt-access-token.strategy.ts
index 6205225a3..45a621187 100644
--- a/src/auth/strategies/jwt-access-token.strategy.ts
+++ b/src/auth/strategies/jwt-access-token.strategy.ts
@@ -3,9 +3,7 @@ import { ConfigService } from '@nestjs/config'
import { PassportStrategy } from '@nestjs/passport'
import { Strategy, ExtractJwt } from 'passport-jwt'
-import {
- isSelfhosted, SELFHOSTED_UUID,
-} from 'src/common/constants'
+import { isSelfhosted, SELFHOSTED_UUID } from 'src/common/constants'
import { generateSelfhostedUser } from 'src/user/entities/user.entity'
import { UserService } from 'src/user/user.service'
import { IJwtPayload } from '../interfaces'
diff --git a/src/common/guards/selfhosted.guard.ts b/src/common/guards/selfhosted.guard.ts
index b8fbcb851..cc82e13bf 100644
--- a/src/common/guards/selfhosted.guard.ts
+++ b/src/common/guards/selfhosted.guard.ts
@@ -1,4 +1,8 @@
-import { Injectable, CanActivate, NotImplementedException } from '@nestjs/common'
+import {
+ Injectable,
+ CanActivate,
+ NotImplementedException,
+} from '@nestjs/common'
import { isSelfhosted } from '../constants'
@Injectable()
diff --git a/src/common/utils.ts b/src/common/utils.ts
index e3268f5b6..348f4bd6a 100644
--- a/src/common/utils.ts
+++ b/src/common/utils.ts
@@ -203,26 +203,34 @@ const createProjectClickhouse = async (project: Project) => {
return clickhouse.query(query, paramsData).toPromise()
}
-const saveRefreshTokenClickhouse = async (userId: string, refreshToken: string) => {
+const saveRefreshTokenClickhouse = async (
+ userId: string,
+ refreshToken: string,
+) => {
const paramsData = {
params: {
userId,
refreshToken,
},
}
- const query = 'INSERT INTO refresh_token (*) VALUES ({userId:String},{refreshToken:String})'
+ const query =
+ 'INSERT INTO refresh_token (*) VALUES ({userId:String},{refreshToken:String})'
return clickhouse.query(query, paramsData).toPromise()
}
-const findRefreshTokenClickhouse = async (userId: string, refreshToken: string) => {
+const findRefreshTokenClickhouse = async (
+ userId: string,
+ refreshToken: string,
+) => {
const paramsData = {
params: {
userId,
refreshToken,
},
}
- const query = 'SELECT * FROM refresh_token WHERE userId = {userId:String} AND refreshToken = {refreshToken:String}'
+ const query =
+ 'SELECT * FROM refresh_token WHERE userId = {userId:String} AND refreshToken = {refreshToken:String}'
return clickhouse.query(query, paramsData).toPromise()
}
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index 41df8902d..8ef6693dc 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -105,7 +105,7 @@ export class ProjectController {
private readonly logger: AppLoggerService,
private readonly actionTokensService: ActionTokensService,
private readonly mailerService: MailerService,
- ) { }
+ ) {}
@Get('/')
@ApiQuery({ name: 'take', required: false })
@@ -767,8 +767,9 @@ export class ProjectController {
ActionTokenType.PROJECT_SHARE,
share.id,
)
- const url = `${isDevelopment ? headers.origin : PRODUCTION_ORIGIN
- }/share/${actionToken.id}`
+ const url = `${
+ isDevelopment ? headers.origin : PRODUCTION_ORIGIN
+ }/share/${actionToken.id}`
await this.mailerService.sendEmail(
invitee.email,
LetterTemplate.ProjectInvitation,
diff --git a/src/user/entities/user.entity.ts b/src/user/entities/user.entity.ts
index 8c46c941f..e174b90ad 100644
--- a/src/user/entities/user.entity.ts
+++ b/src/user/entities/user.entity.ts
@@ -14,9 +14,7 @@ import { ExtensionToUser } from '../../marketplace/extensions/entities/extension
import { Comment } from '../../marketplace/comments/entities/comment.entity'
import { Complaint } from '../../marketplace/complaints/entities/complaint.entity'
import { RefreshToken } from './refresh-token.entity'
-import {
- SELFHOSTED_EMAIL, SELFHOSTED_UUID,
-} from '../../common/constants'
+import { SELFHOSTED_EMAIL, SELFHOSTED_UUID } from '../../common/constants'
export enum PlanCode {
none = 'none',