📈 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
use deriveKey
Blue Mouse2b4995116244
diff --git a/backend/apps/cloud/src/common/utils.ts b/backend/apps/cloud/src/common/utils.tsindex 34cade399..917a2ca16 100644--- a/backend/apps/cloud/src/common/utils.ts+++ b/backend/apps/cloud/src/common/utils.ts@@ -31,7 +31,7 @@ export const hash = (content: string): string => {* Derives a key from the SECRET_KEY_BASE environment variable using the HKDF algorithm.*/export const deriveKey = (- purpose: 'refresh-token' | 'access-token' | 'gsc-token',+ purpose: 'refresh-token' | 'access-token' | 'gsc-token' | 'revenue',length = 32,) => {const base = Buffer.from(process.env.SECRET_KEY_BASE || '', 'utf8')diff --git a/backend/apps/cloud/src/revenue/revenue.service.ts b/backend/apps/cloud/src/revenue/revenue.service.tsindex 09b943eef..3a6cd755b 100644--- a/backend/apps/cloud/src/revenue/revenue.service.ts+++ b/backend/apps/cloud/src/revenue/revenue.service.ts@@ -18,6 +18,7 @@ import {RevenueTransactionDto,RevenueBreakdownDto,} from './dto/revenue-stats.dto'+import { deriveKey } from '../common/utils'const timeBucketConversion: Record<string, string> = {minute: 'toStartOfMinute',@@ -36,8 +37,7 @@ export class RevenueService {private readonly projectRepository: Repository<Project>,private readonly logger: AppLoggerService,) {- // Use a 32-byte key from JWT_ACCESS_TOKEN_SECRET- const secret = process.env.JWT_ACCESS_TOKEN_SECRET || 'default-secret-key'+ const secret = deriveKey('revenue', 32)this.encryptionKey = crypto.scryptSync(secret, 'revenue-salt', 32)}