/**
 * Security Route Helper Functions
 *
 * This module provides utility functions for adding security features to routes.
 */
import { mergeRouteConfigs } from '../route-utils.js';
/**
 * Create a rate limiting route pattern
 * @param baseRoute Base route to add rate limiting to
 * @param rateLimit Rate limiting configuration
 * @returns Route with rate limiting
 */
export function addRateLimiting(baseRoute, rateLimit) {
    return mergeRouteConfigs(baseRoute, {
        security: {
            rateLimit: {
                enabled: true,
                maxRequests: rateLimit.maxRequests,
                window: rateLimit.window,
                keyBy: rateLimit.keyBy || 'ip',
                headerName: rateLimit.headerName,
                errorMessage: rateLimit.errorMessage || 'Rate limit exceeded. Please try again later.'
            }
        }
    });
}
/**
 * Create a basic authentication route pattern
 * @param baseRoute Base route to add authentication to
 * @param auth Authentication configuration
 * @returns Route with basic authentication
 */
export function addBasicAuth(baseRoute, auth) {
    return mergeRouteConfigs(baseRoute, {
        security: {
            basicAuth: {
                enabled: true,
                users: auth.users,
                realm: auth.realm || 'Restricted Area',
                excludePaths: auth.excludePaths || []
            }
        }
    });
}
/**
 * Create a JWT authentication route pattern
 * @param baseRoute Base route to add JWT authentication to
 * @param jwt JWT authentication configuration
 * @returns Route with JWT authentication
 */
export function addJwtAuth(baseRoute, jwt) {
    return mergeRouteConfigs(baseRoute, {
        security: {
            jwtAuth: {
                enabled: true,
                secret: jwt.secret,
                algorithm: jwt.algorithm || 'HS256',
                issuer: jwt.issuer,
                audience: jwt.audience,
                expiresIn: jwt.expiresIn,
                excludePaths: jwt.excludePaths || []
            }
        }
    });
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VjdXJpdHktaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3RzL3Byb3hpZXMvc21hcnQtcHJveHkvdXRpbHMvcm91dGUtaGVscGVycy9zZWN1cml0eS1oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7O0dBSU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