mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
15 lines
390 B
JavaScript
15 lines
390 B
JavaScript
// @flow
|
|
|
|
import type { RequestHeader } from '../../models/request';
|
|
|
|
export function getBasicAuthHeader(
|
|
username: ?string,
|
|
password: ?string
|
|
): RequestHeader {
|
|
const name = 'Authorization';
|
|
const header = `${username || ''}:${password || ''}`;
|
|
const authString = Buffer.from(header, 'utf8').toString('base64');
|
|
const value = `Basic ${authString}`;
|
|
return { name, value };
|
|
}
|