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!

Remove xxhash; use SHA256 instead

Blue Mouse607485b08a65
diff --git a/backend/apps/community/src/common/utils.ts b/backend/apps/community/src/common/utils.ts
index 5ca7e42e1..77bd38e79 100644
--- a/backend/apps/community/src/common/utils.ts
+++ b/backend/apps/community/src/common/utils.ts
@@ -1,5 +1,4 @@
import { NotFoundException, HttpException } from '@nestjs/common'
-import { xxh3 } from '@node-rs/xxhash'
import path from 'path'
import fs from 'fs'
import crypto from 'crypto'
@@ -41,10 +40,15 @@ import { ClickhouseFunnel, ClickhouseSFUser } from './types'
dayjs.extend(utc)
/*
- Returns 128 bit (a string of 32 chars) hash of the provided string using xxHash algo.
+ Returns a 32-character hash of the provided string using Node.js crypto module.
+ (SHA-256 truncated to 32 chars)
*/
export const hash = (content: string): string => {
- return xxh3.xxh128(content).toString(16)
+ return crypto
+ .createHash('sha256')
+ .update(content)
+ .digest('hex')
+ .substring(0, 32)
}
export const generateRandomId = (alphabet: string, size: number) => {
diff --git a/backend/package-lock.json b/backend/package-lock.json
index 62ecd4422..68292a3d5 100644
--- a/backend/package-lock.json
+++ b/backend/package-lock.json
@@ -22,7 +22,6 @@
"@nestjs/swagger": "^11.1.3",
"@nestjs/terminus": "^11.0.0",
"@nestjs/typeorm": "^11.0.0",
- "@node-rs/xxhash": "^1.7.6",
"@paypal/payouts-sdk": "^1.1.1",
"@sentry/cli": "^2.43.0",
"@sentry/nestjs": "^9.13.0",
@@ -100,10 +99,6 @@
},
"engines": {
"node": ">=22"
- },
- "optionalDependencies": {
- "@node-rs/xxhash-linux-arm64-musl": "^1.7.6",
- "@node-rs/xxhash-linux-x64-musl": "^1.7.6"
}
},
"node_modules/@angular-devkit/core": {
@@ -1912,83 +1907,6 @@
"typeorm": "^0.3.0"
}
},
- "node_modules/@node-rs/xxhash": {
- "version": "1.7.6",
- "resolved": "https://registry.npmjs.org/@node-rs/xxhash/-/xxhash-1.7.6.tgz",
- "integrity": "sha512-XMisO+aQHsVpxRp/85EszTtOQTOlhPbd149P/Xa9F55wafA6UM3h2UhOgOs7aAzItnHU/Aw1WQ1FVTEg7WB43Q==",
- "license": "MIT",
- "engines": {
- "node": ">= 12"
- },
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/Brooooooklyn"
- },
- "optionalDependencies": {
- "@node-rs/xxhash-android-arm-eabi": "1.7.6",
- "@node-rs/xxhash-android-arm64": "1.7.6",
- "@node-rs/xxhash-darwin-arm64": "1.7.6",
- "@node-rs/xxhash-darwin-x64": "1.7.6",
- "@node-rs/xxhash-freebsd-x64": "1.7.6",
- "@node-rs/xxhash-linux-arm-gnueabihf": "1.7.6",
- "@node-rs/xxhash-linux-arm64-gnu": "1.7.6",
- "@node-rs/xxhash-linux-arm64-musl": "1.7.6",
- "@node-rs/xxhash-linux-x64-gnu": "1.7.6",
- "@node-rs/xxhash-linux-x64-musl": "1.7.6",
- "@node-rs/xxhash-wasm32-wasi": "1.7.6",
- "@node-rs/xxhash-win32-arm64-msvc": "1.7.6",
- "@node-rs/xxhash-win32-ia32-msvc": "1.7.6",
- "@node-rs/xxhash-win32-x64-msvc": "1.7.6"
- }
- },
- "node_modules/@node-rs/xxhash-darwin-arm64": {
- "version": "1.7.6",
- "resolved": "https://registry.npmjs.org/@node-rs/xxhash-darwin-arm64/-/xxhash-darwin-arm64-1.7.6.tgz",
- "integrity": "sha512-6xGuE07CiCIry/KT3IiwQd/kykTOmjKzO/ZnHlE5ibGMx64NFE0qDuwJbxQ4rGyUzgJ0KuN9ZdOhUDJmepnpcw==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": ">= 12"
- }
- },
- "node_modules/@node-rs/xxhash-linux-arm64-musl": {
- "version": "1.7.6",
- "resolved": "https://registry.npmjs.org/@node-rs/xxhash-linux-arm64-musl/-/xxhash-linux-arm64-musl-1.7.6.tgz",
- "integrity": "sha512-AB5m6crGYSllM9F/xZNOQSPImotR5lOa9e4arW99Bv82S+gcpphI8fGMDOVTTCXY/RLRhvvhwzLDxmLB2O8VDg==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">= 12"
- }
- },
- "node_modules/@node-rs/xxhash-linux-x64-musl": {
- "version": "1.7.6",
- "resolved": "https://registry.npmjs.org/@node-rs/xxhash-linux-x64-musl/-/xxhash-linux-x64-musl-1.7.6.tgz",
- "integrity": "sha512-WioGJSC1GoxQpmdQrG5l/uddSBAS4XCWczHNwXe895J5xadGQzyvmr0r17BNfihvbBUDH1H9jwouNYzDDeA6+A==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">= 12"
- }
- },
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
diff --git a/backend/package.json b/backend/package.json
index 4ec69a847..1f4ff16b5 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -41,7 +41,6 @@
"@nestjs/swagger": "^11.1.3",
"@nestjs/terminus": "^11.0.0",
"@nestjs/typeorm": "^11.0.0",
- "@node-rs/xxhash": "^1.7.6",
"@paypal/payouts-sdk": "^1.1.1",
"@sentry/cli": "^2.43.0",
"@sentry/nestjs": "^9.13.0",
@@ -93,10 +92,6 @@
"uuid": "^11.1.0",
"validator": "^13.15.0"
},
- "optionalDependencies": {
- "@node-rs/xxhash-linux-arm64-musl": "^1.7.6",
- "@node-rs/xxhash-linux-x64-musl": "^1.7.6"
- },
"devDependencies": {
"@eslint/js": "^9.24.0",
"@nestjs/cli": "^11.0.6",