import { getPolicyResponseCode } from "./getPolicyResponseCode";
/**
 * Validate authentication policy
 * @param policy
 * @param context
 * @param entity
 * @returns
 */
export function checkAuthentication(policy, context, _entity) {
    const checks = [];
    // Only return a check if the policy is defined
    if (Object.prototype.hasOwnProperty.call(policy, "authenticated")) {
        let response = "granted";
        if (policy.authenticated && !context.isAuthenticated) {
            response = "not-authenticated";
        }
        // create the check
        const check = {
            name: "authentication",
            value: `required: ${(!!policy.authenticated).toString()}`,
            code: getPolicyResponseCode(response),
            response,
        };
        checks.push(check);
    }
    return checks;
}
//# sourceMappingURL=checkAuthentication.js.map