All files / packages/dataflint-mcp/src auth-scopes.ts

100% Statements 12/12
100% Branches 4/4
100% Functions 1/1
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 151x   1x 1x   1x 6x 6x 1x 1x 1x 1x 5x 5x  
const BASELINE_SCOPES = ["openid", "email", "offline_access"] as const;
 
const FORBIDDEN_SCOPE =
    /^(read|update|delete|create):(users|roles|clients|connections|grants|rules)$/;
 
export function mergeScopes(extra: readonly string[]): string {
    const forbidden = extra.filter((s) => FORBIDDEN_SCOPE.test(s));
    if (forbidden.length > 0) {
        throw new Error(
            `Refusing forbidden scopes from backend: ${forbidden.join(", ")}`
        );
    }
    return Array.from(new Set([...BASELINE_SCOPES, ...extra])).join(" ");
}