17 lines
619 B
TypeScript
Raw Normal View History

export { parseNodeList, parsePairingList } from "../../shared/node-list-parse.js";
2026-01-14 01:08:15 +00:00
export function formatPermissions(raw: unknown) {
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
return null;
}
2026-01-14 01:08:15 +00:00
const entries = Object.entries(raw as Record<string, unknown>)
.map(([key, value]) => [String(key).trim(), value === true] as const)
.filter(([key]) => key.length > 0)
.toSorted((a, b) => a[0].localeCompare(b[0]));
if (entries.length === 0) {
return null;
}
const parts = entries.map(([key, granted]) => `${key}=${granted ? "yes" : "no"}`);
2026-01-14 01:08:15 +00:00
return `[${parts.join(", ")}]`;
}