Innovenergy_trunk/frontend/node_modules/testcafe-hammerhead/lib/utils/headers.js

48 lines
2.5 KiB
JavaScript

"use strict";
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAuthorizationHeader = exports.removeAuthorizationPrefix = exports.hasAuthorizationPrefix = exports.addAuthorizationPrefix = exports.isAuthenticateHeader = exports.removeAuthenticatePrefix = exports.hasAuthenticatePrefix = exports.addAuthenticatePrefix = void 0;
const builtin_header_names_1 = __importDefault(require("../request-pipeline/builtin-header-names"));
const AUTHENTICATE_PREFIX = '~~~TestCafe added this prefix to hide the authentication dialog box~~~';
const AUTHORIZATION_PREFIX = '~~~TestCafe added this prefix to control the authorization flow~~~';
function addAuthenticatePrefix(value) {
return AUTHENTICATE_PREFIX + value;
}
exports.addAuthenticatePrefix = addAuthenticatePrefix;
function hasAuthenticatePrefix(value) {
return value.indexOf(AUTHENTICATE_PREFIX) > -1;
}
exports.hasAuthenticatePrefix = hasAuthenticatePrefix;
function removeAuthenticatePrefix(value) {
return value.replace(AUTHENTICATE_PREFIX, '');
}
exports.removeAuthenticatePrefix = removeAuthenticatePrefix;
function isAuthenticateHeader(headerName) {
const headerNameStr = String(headerName).toLowerCase();
return headerNameStr === builtin_header_names_1.default.wwwAuthenticate || headerNameStr === builtin_header_names_1.default.proxyAuthenticate;
}
exports.isAuthenticateHeader = isAuthenticateHeader;
function addAuthorizationPrefix(value) {
return AUTHORIZATION_PREFIX + value;
}
exports.addAuthorizationPrefix = addAuthorizationPrefix;
function hasAuthorizationPrefix(value) {
return value.indexOf(AUTHORIZATION_PREFIX) > -1;
}
exports.hasAuthorizationPrefix = hasAuthorizationPrefix;
function removeAuthorizationPrefix(value) {
return value.replace(AUTHORIZATION_PREFIX, '');
}
exports.removeAuthorizationPrefix = removeAuthorizationPrefix;
function isAuthorizationHeader(headerName) {
const headerNameStr = String(headerName).toLowerCase();
return headerNameStr === builtin_header_names_1.default.authorization || headerNameStr === builtin_header_names_1.default.proxyAuthorization;
}
exports.isAuthorizationHeader = isAuthorizationHeader;