MCPcopy Create free account
hub / github.com/Kong/insomnia / getBasicAuthHeader

Function getBasicAuthHeader

packages/insomnia/src/network/basic-auth/get-header.ts:5–15  ·  view source on GitHub ↗
(username?: string | null, password?: string | null, encoding = 'utf8')

Source from the content-addressed store, hash-verified

3import { bytesToBase64, latin1BytesFromString, utf8ToBase64 } from '~/common/utils/utf8-bytes';
4
5export function getBasicAuthHeader(username?: string | null, password?: string | null, encoding = 'utf8') {
6 const name = 'Authorization';
7 const header = `${username || ''}:${password || ''}`;
8 const authString = encoding === 'latin1' ? bytesToBase64(latin1BytesFromString(header)) : utf8ToBase64(header);
9 const value = `Basic ${authString}`;
10 const requestHeader: RequestHeader = {
11 name,
12 value,
13 };
14 return requestHeader;
15}

Callers 6

get-header.test.tsFile · 0.90
getAuthHeaderFunction · 0.90
openWebSocketConnectionFunction · 0.90
getOAuth2TokenFunction · 0.90
McpUrlActionBarFunction · 0.90

Calls 3

bytesToBase64Function · 0.90
latin1BytesFromStringFunction · 0.90
utf8ToBase64Function · 0.90

Tested by

no test coverage detected