"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createYTAuthorizationResolver = createYTAuthorizationResolver;
const constants_1 = require("../../shared/constants");
const utils_1 = require("../utils");
function createYTAuthorizationResolver() {
    return async function resolveYTAuthorization(req, res, next) {
        const { ytAuthCluster } = req.params;
        const secret = req.cookies[(0, utils_1.makeAuthClusterCookieName)(ytAuthCluster)];
        if (ytAuthCluster) {
            res.setHeader(constants_1.YT_UI_CLUSTER_HEADER_NAME, ytAuthCluster);
        }
        req.yt = {
            ytApiAuthHeaders: {
                Cookie: `${constants_1.YT_CYPRESS_COOKIE_NAME}=${secret};`,
            },
        };
        next();
    };
}
