mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 23:35:20 +00:00
Adds electoral nuclei, leaderships, updates, and WhatsApp invite flows behind campaign auth, plus the consolidated schema migration that Vercel applies on deploy.
17 lines
575 B
TypeScript
17 lines
575 B
TypeScript
import { createHash } from 'node:crypto'
|
|
|
|
const canonicalize = (value: unknown): unknown => {
|
|
if (Array.isArray(value)) return value.map(canonicalize)
|
|
if (value === null || typeof value !== 'object') return value
|
|
|
|
return Object.fromEntries(
|
|
Object.entries(value)
|
|
.sort(([left], [right]) => left.localeCompare(right))
|
|
.map(([key, nestedValue]) => [key, canonicalize(nestedValue)]),
|
|
)
|
|
}
|
|
|
|
export const hashConsentContent = (content: unknown): string =>
|
|
createHash('sha256')
|
|
.update(JSON.stringify(canonicalize(content)), 'utf8')
|
|
.digest('hex')
|