/* * Utility functions for SaaS VOC Cloud Functions */ /** * Generate a unique public ID */ function publicId() { return 'cf-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10); } /** * Safely serialize a value, removing sensitive fields */ function safeValue(value, depth) { if (depth > 5 || value === null || value === undefined) return value; if (value instanceof Date) return value; if (Array.isArray(value)) return value.slice(0, 100).map((item) => safeValue(item, depth + 1)); if (typeof value !== 'object') return value; const output = {}; Object.keys(value).slice(0, 100).forEach((key) => { if (/token|secret|password|credential|authorization|master/i.test(key)) return; output[key] = safeValue(value[key], depth + 1); }); return output; } /** * Limit a value to a bounded range */ function boundedLimit(value, fallback, maximum = 100) { const limit = Number(value || fallback); return Number.isInteger(limit) ? Math.max(1, Math.min(limit, maximum)) : fallback; } /* // module.exports = { // publicId, // safeValue, // boundedLimit, // }; */