ya-express-ntlm
Version:
28 lines • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleNegotiate = void 0;
const af_color_1 = require("af-color");
const ProxyCache_1 = require("./proxy/ProxyCache");
const debug_1 = require("./debug");
const ntlm_parser_1 = require("../ntlm-parser");
const constants_1 = require("./lib/constants");
const handleNegotiate = async (rsn, messageType1) => {
const { res, options } = rsn;
try {
rsn.payload = messageType1;
const proxyId = options.getProxyId(rsn);
const messageType2 = await ProxyCache_1.proxyCache.addOrReplace(rsn, proxyId, messageType1);
const messageType2Parsed = (0, ntlm_parser_1.ntlmParse)(messageType2, { compact: true });
options.onMessageType2(rsn, messageType2Parsed, ProxyCache_1.proxyCache, proxyId);
res.setHeader('WWW-Authenticate', `NTLM ${messageType2}`).status(401).end();
if (debug_1.debugNtlmAuthFlow.enabled) {
(0, debug_1.debugNtlmAuthFlow)(`${constants_1.Larrow} Return ${af_color_1.blue}401${af_color_1.reset} ${debug_1.hnColor}WWW-Authenticate${af_color_1.blue}: ${debug_1.hvOutColor}NTLM ${messageType2}`);
(0, debug_1.debugNtlmAuthFlow)(`Decoded MessageType2: ${debug_1.hvOutColor}${JSON.stringify(messageType2Parsed, undefined, 2)}`);
}
}
catch (err) {
return options.handleHttpError500(res, err);
}
};
exports.handleNegotiate = handleNegotiate;
//# sourceMappingURL=handle-negotiate.js.map