Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import dbg from 'debug';
import fetch, { RequestInit, Response } from 'node-fetch';
import { AbstractHandler } from './AbstractHandler';
import { ClientCookie } from './ClientCookie';
import { ClientInfo } from './ClientInfo';
import { encodeBase64 } from './misc';
const debug = dbg('node-expose-sspi:client');
export class BasicHandler extends AbstractHandler {
async handle(
clientInfo: ClientInfo,
clientCookie: ClientCookie,
response: Response,
resource: string,
init: RequestInit = {}
): Promise<Response> {
debug('basic handler');
const requestInit: RequestInit = { ...init };
const str = clientInfo.user + ':' + clientInfo.password;
requestInit.headers = {
...init.headers,
Authorization: 'Basic ' + encodeBase64(str),
};
clientCookie.restituteCookies(requestInit);
debug('first requestInit.headers', requestInit.headers);
response = await fetch(resource, requestInit);
debug('first response.headers', response.headers);
clientCookie.saveCookies(response);
return response;
}
}
|