📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
remove UUID package in favour of native crypto solution
Blue Mouse377ec6b5a839
diff --git a/backend/apps/cloud/src/auth/auth.service.ts b/backend/apps/cloud/src/auth/auth.service.tsindex bccca1808..69b1bfe0a 100644--- a/backend/apps/cloud/src/auth/auth.service.ts+++ b/backend/apps/cloud/src/auth/auth.service.ts@@ -1,4 +1,4 @@-import { createHash } from 'crypto'+import { createHash, randomUUID } from 'crypto'import {Injectable,InternalServerErrorException,@@ -17,7 +17,6 @@ import _pick from 'lodash/pick'import _split from 'lodash/split'import _isEmpty from 'lodash/isEmpty'import _find from 'lodash/find'-import { v4 as uuidv4 } from 'uuid'import {ActionToken,@@ -51,7 +50,8 @@ import { UserGithubDTO } from '../user/dto/user-github.dto'const REDIS_SSO_SESSION_TIMEOUT = 60 * 5 // 5 minutesconst getSSORedisKey = (uuid: string) => `${REDIS_SSO_UUID}:${uuid}`-const generateSSOState = (provider: SSOProviders) => `${provider}:${uuidv4()}`+const generateSSOState = (provider: SSOProviders) =>+ `${provider}:${randomUUID()}`const getSSOSessionProvider = (state: string): SSOProviders =>_split(state, ':')[0] as SSOProvidersdiff --git a/backend/apps/cloud/src/marketplace/cdn/cdn.service.ts b/backend/apps/cloud/src/marketplace/cdn/cdn.service.tsindex 2d44c8066..4b263be77 100644--- a/backend/apps/cloud/src/marketplace/cdn/cdn.service.ts+++ b/backend/apps/cloud/src/marketplace/cdn/cdn.service.ts@@ -6,7 +6,7 @@ import { ConfigService } from '@nestjs/config'import { Injectable, InternalServerErrorException } from '@nestjs/common'import FormData from 'form-data'import { HttpService } from '@nestjs/axios'-import { v4 as uuidv4 } from 'uuid'+import { randomUUID } from 'crypto'@Injectable()export class CdnService {@@ -24,7 +24,7 @@ export class CdnService {try {// Generate a safe filename using UUID to prevent path traversal attacksconst fileExtension = extname(file.originalName || '')- const safeFilename = `${uuidv4()}${fileExtension}`+ const safeFilename = `${randomUUID()}${fileExtension}`const filePath = `${tmpdir()}/${safeFilename}`await writeFile(filePath, file.buffer)diff --git a/backend/apps/cloud/src/user/user.controller.ts b/backend/apps/cloud/src/user/user.controller.tsindex df931c027..85c99be2d 100644--- a/backend/apps/cloud/src/user/user.controller.ts+++ b/backend/apps/cloud/src/user/user.controller.ts@@ -31,7 +31,7 @@ import _includes from 'lodash/includes'import _isString from 'lodash/isString'import _pick from 'lodash/pick'import _round from 'lodash/round'-import { v4 as uuidv4 } from 'uuid'+import { randomUUID } from 'crypto'import { HttpService } from '@nestjs/axios'import { catchError, firstValueFrom, map, of } from 'rxjs'@@ -290,7 +290,7 @@ export class UserController {throw new ConflictException('You already have an API key')}- const apiKey: string = uuidv4()+ const apiKey: string = randomUUID()await this.userService.update(userId, { apiKey })diff --git a/backend/apps/community/src/auth/auth.controller.ts b/backend/apps/community/src/auth/auth.controller.tsindex 367291e4e..c62ea0f01 100644--- a/backend/apps/community/src/auth/auth.controller.ts+++ b/backend/apps/community/src/auth/auth.controller.ts@@ -25,6 +25,7 @@ import {ApiBearerAuth,} from '@nestjs/swagger'import { I18nValidationExceptionFilter, I18n, I18nContext } from 'nestjs-i18n'+import { randomUUID } from 'crypto'import { Response } from 'express'import { checkRateLimit, getIPFromHeaders } from '../common/utils'@@ -49,7 +50,6 @@ import { UserType } from '../user/entities/user.entity'import { LetterTemplate } from '../mailer/letter'import { MailerService } from '../mailer/mailer.service'import { redis } from '../common/constants'-import { v4 as uuidv4 } from 'uuid'import { OIDC_ENABLED, OIDC_ONLY_AUTH } from '../common/constants'import { UserService } from '../user/user.service'@@ -204,7 +204,7 @@ export class AuthController {throw new ConflictException(i18n.t('user.emailAlreadyUsed'))}- const token = uuidv4()+ const token = randomUUID()await redis.set(`email_change:${token}`,JSON.stringify({ id: user.id, newEmail: body.newEmail }),diff --git a/backend/apps/community/src/auth/auth.service.ts b/backend/apps/community/src/auth/auth.service.tsindex fd369bab6..a2d616f29 100644--- a/backend/apps/community/src/auth/auth.service.ts+++ b/backend/apps/community/src/auth/auth.service.ts@@ -1,4 +1,4 @@-import { createHash, randomBytes } from 'crypto'+import { createHash, randomBytes, randomUUID } from 'crypto'import {BadRequestException,ConflictException,@@ -10,7 +10,6 @@ import { JwtService } from '@nestjs/jwt'import { genSalt, hash, compare } from 'bcrypt'import axios from 'axios'import _isEmpty from 'lodash/isEmpty'-import { v4 as uuidv4 } from 'uuid'import { decode, JwtPayload, verify } from 'jsonwebtoken'import jwksClient from 'jwks-rsa'@@ -37,7 +36,7 @@ import { LetterTemplate } from '../mailer/letter'const REDIS_OIDC_SESSION_TIMEOUT = 60 * 5 // 5 minutesconst getOIDCRedisKey = (uuid: string) => `${REDIS_OIDC_SESSION_KEY}:${uuid}`-const generateOIDCState = () => `openid-connect:${uuidv4()}`+const generateOIDCState = () => `openid-connect:${randomUUID()}`@Injectable()export class AuthService {@@ -169,7 +168,7 @@ export class AuthService {) {const urlBase = headers.origin || ''- const token = uuidv4()+ const token = randomUUID()const url = `${urlBase}/password-reset/${token}`await redis.set(`password_reset:${token}`, userId, 'EX', 60 * 60 * 12)diff --git a/backend/apps/community/src/project/project.controller.ts b/backend/apps/community/src/project/project.controller.tsindex d27594c17..d5e94c4cc 100644--- a/backend/apps/community/src/project/project.controller.ts+++ b/backend/apps/community/src/project/project.controller.ts@@ -18,7 +18,7 @@ import {ParseIntPipe,ConflictException,} from '@nestjs/common'-import { v4 as uuidv4 } from 'uuid'+import { randomUUID } from 'crypto'import {ApiTags,ApiQuery,@@ -387,7 +387,7 @@ export class ProjectController {)}- const id = uuidv4()+ const id = randomUUID()await this.mailerService.sendEmail(invitee.email,@@ -538,7 +538,7 @@ export class ProjectController {this.projectService.allowedToManage(project, userId)const funnel = new Funnel()- funnel.id = uuidv4()+ funnel.id = randomUUID()funnel.name = funnelDTO.namefunnel.steps = _map(funnelDTO.steps, _trim) as string[]funnel.projectId = funnelDTO.pid@@ -983,7 +983,7 @@ export class ProjectController {this.projectService.allowedToManage(project, userId)- const viewId = uuidv4()+ const viewId = randomUUID()const { customEvents } = body@@ -994,7 +994,7 @@ export class ProjectController {customEvents[i] = {...customEvent,// @ts-expect-error- id: uuidv4(),+ id: randomUUID(),}}}diff --git a/backend/apps/community/src/project/project.service.ts b/backend/apps/community/src/project/project.service.tsindex e54b81182..fac5d1f1e 100644--- a/backend/apps/community/src/project/project.service.ts+++ b/backend/apps/community/src/project/project.service.ts@@ -7,6 +7,7 @@ import {InternalServerErrorException,ConflictException,} from '@nestjs/common'+import { randomUUID } from 'crypto'import _isEmpty from 'lodash/isEmpty'import _isString from 'lodash/isString'import _size from 'lodash/size'@@ -21,7 +22,6 @@ import _trim from 'lodash/trim'import _reduce from 'lodash/reduce'import _findIndex from 'lodash/findIndex'import { compareSync } from 'bcrypt'-import { v4 as uuidv4 } from 'uuid'import { Project, ProjectWithShare, Role } from './entity/project.entity'import { ProjectDTO } from './dto/project.dto'@@ -180,7 +180,7 @@ export class ProjectService {)await createProjectShareClickhouse({- id: uuidv4(),+ id: randomUUID(),userId: oldAdminId,projectId: projectId,confirmed: 1,diff --git a/backend/apps/community/src/user/user.controller.ts b/backend/apps/community/src/user/user.controller.tsindex 3af19a672..05ca7b430 100644--- a/backend/apps/community/src/user/user.controller.ts+++ b/backend/apps/community/src/user/user.controller.ts@@ -16,7 +16,7 @@ import { ApiBearerAuth, ApiResponse, ApiTags } from '@nestjs/swagger'import _isEmpty from 'lodash/isEmpty'import _omit from 'lodash/omit'import _isNull from 'lodash/isNull'-import { v4 as uuidv4 } from 'uuid'+import { randomUUID } from 'crypto'import { JwtAccessTokenGuard } from '../auth/guards'import { OnboardingStep, UserType } from './entities/user.entity'@@ -253,7 +253,7 @@ export class UserController {throw new ConflictException('You already have an API key')}- const apiKey: string = uuidv4()+ const apiKey: string = randomUUID()await this.userService.update(userId, { apiKey })@@ -325,7 +325,7 @@ export class UserController {// TODO: Change this if we introduce CLIENT_URL in CE as .env variableconst urlBase = request.headers.origin || ''- const token = uuidv4()+ const token = randomUUID()const url = `${urlBase}/change-email/${token}`await this.mailerService.sendEmail(diff --git a/backend/apps/community/src/user/user.service.ts b/backend/apps/community/src/user/user.service.tsindex ba742ec3a..b18b0cd54 100644--- a/backend/apps/community/src/user/user.service.ts+++ b/backend/apps/community/src/user/user.service.ts@@ -1,5 +1,5 @@import { BadRequestException, Injectable } from '@nestjs/common'-import { v4 as uuidv4 } from 'uuid'+import { randomUUID } from 'crypto'import _omit from 'lodash/omit'import _isEmpty from 'lodash/isEmpty'import _size from 'lodash/size'@@ -121,7 +121,7 @@ export class UserService {}async create(user: Pick<ClickhouseInputUser, 'email' | 'password'>) {- const id = uuidv4()+ const id = randomUUID()await clickhouse.insert({table: 'user',diff --git a/backend/package-lock.json b/backend/package-lock.jsonindex e7f64e087..5584a50c4 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -69,7 +69,6 @@"svg-captcha": "^1.4.0","telegraf": "^4.16.3","typeorm": "^0.3.27",- "uuid": "^11.1.0","validator": "^13.15.15"},"devDependencies": {diff --git a/backend/package.json b/backend/package.jsonindex fb1eafb17..ccfda5efa 100644--- a/backend/package.json+++ b/backend/package.json@@ -88,7 +88,6 @@"svg-captcha": "^1.4.0","telegraf": "^4.16.3","typeorm": "^0.3.27",- "uuid": "^11.1.0","validator": "^13.15.15"},"devDependencies": {