mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
9d4390de2f
Co-authored-by: Opender Singh <opender94@gmail.com>
16 lines
423 B
JavaScript
16 lines
423 B
JavaScript
// @flow
|
|
|
|
import type { RequestHeader } from '../../models/request';
|
|
|
|
export function getBasicAuthHeader(
|
|
username: ?string,
|
|
password: ?string,
|
|
encoding: ?string = 'utf8',
|
|
): RequestHeader {
|
|
const name = 'Authorization';
|
|
const header = `${username || ''}:${password || ''}`;
|
|
const authString = Buffer.from(header, encoding).toString('base64');
|
|
const value = `Basic ${authString}`;
|
|
return { name, value };
|
|
}
|