mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
182ed56fa4
Every shareable field of a place now records where its value came from: typed by a user, filled by a provider, written by the assistant, a plugin or an import. Only values a user typed are ever sent, and only after an admin agreed to the current terms for the whole installation, field by field. The new place-contrib domain keeps the decision in app settings, queues values in an outbox a cron job sends from, logs what the service made of each one and can withdraw everything this installation sent. Development, test and demo instances, an own TREK_PLACES_URL, TREK_SERVICES=off and TREK_PLACES_CONTRIBUTE=off never send anything. Index results carry the community version, so the details caches refresh when it changes.
12 lines
464 B
TypeScript
12 lines
464 B
TypeScript
import { createHash } from 'node:crypto';
|
|
|
|
/**
|
|
* The SHA-256 of a stored value, hex. The origin of a place's field is kept
|
|
* with the hash of the value it describes, so a value changed by any path that
|
|
* did not record an origin (a migration, a direct SQL fix, an older plugin SDK,
|
|
* a restore) no longer matches and counts as unknown.
|
|
*/
|
|
export function valueHash(value: string): string {
|
|
return createHash('sha256').update(value, 'utf8').digest('hex');
|
|
}
|