import { createHash } from 'node:crypto';
export function sha256(value) {
    return createHash('sha256').update(value).digest('hex');
}
export function stableJson(value) {
    return JSON.stringify(sortKeys(value));
}
function sortKeys(value) {
    if (Array.isArray(value)) {
        return value.map(sortKeys);
    }
    if (value && typeof value === 'object') {
        return Object.fromEntries(Object.entries(value)
            .sort(([left], [right]) => left.localeCompare(right))
            .map(([key, nested]) => [key, sortKeys(nested)]));
    }
    return value;
}
