MCPcopy Create free account
hub / github.com/pollinations/pollinations / normalizePermissions

Function normalizePermissions

shared/auth/api-key.ts:273–289  ·  view source on GitHub ↗
(
    value: unknown,
)

Source from the content-addressed store, hash-verified

271}
272
273function normalizePermissions(
274 value: unknown,
275): Record<string, string[]> | undefined {
276 if (!value || typeof value !== "object" || Array.isArray(value)) {
277 return undefined;
278 }
279
280 const permissions: Record<string, string[]> = {};
281 for (const [key, scopes] of Object.entries(value)) {
282 if (!Array.isArray(scopes)) continue;
283 const safeScopes = scopes.filter(
284 (scope): scope is string => typeof scope === "string",
285 );
286 if (safeScopes.length) permissions[key] = safeScopes;
287 }
288 return Object.keys(permissions).length ? permissions : undefined;
289}
290
291function normalizeMetadata(
292 value: unknown,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected