"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2024-2026 Gracker (Chris)
// This file is part of SmartPerfetto. See LICENSE for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.requireCodebaseScope = requireCodebaseScope;
exports.hasCodebaseScope = hasCodebaseScope;
const auth_1 = require("../../middleware/auth");
const rbac_1 = require("../rbac");
function requireCodebaseScope(scope) {
    return (req, res, next) => {
        const context = (0, auth_1.requireRequestContext)(req);
        if (!(0, rbac_1.hasRbacPermission)(context, scope)) {
            (0, rbac_1.sendForbidden)(res, `${scope} permission is required`);
            return;
        }
        next();
    };
}
function hasCodebaseScope(req, scope) {
    return (0, rbac_1.hasRbacPermission)((0, auth_1.requireRequestContext)(req), scope);
}
//# sourceMappingURL=codebaseScopes.js.map