MCPcopy Create free account
hub / github.com/massCodeIO/massCode / authHeaders

Function authHeaders

src/renderer/components/http/requestPreview.ts:97–115  ·  view source on GitHub ↗
(auth: HttpAuth)

Source from the content-addressed store, hash-verified

95}
96
97function authHeaders(auth: HttpAuth): HttpHeaderEntry[] {
98 if (auth.type === 'bearer' && auth.token) {
99 return [{ key: 'Authorization', value: `Bearer ${auth.token}` }]
100 }
101
102 if (auth.type === 'basic' && auth.username !== undefined) {
103 return [
104 {
105 key: 'Authorization',
106 value: `Basic ${encodeBasicCredentials(
107 auth.username,
108 auth.password ?? '',
109 )}`,
110 },
111 ]
112 }
113
114 return []
115}
116
117function hasHeader(headers: HttpHeaderEntry[], name: string): boolean {
118 return headers.some(header => header.key.toLowerCase() === name)

Callers 1

getPreviewHeadersFunction · 0.85

Calls 1

encodeBasicCredentialsFunction · 0.85

Tested by

no test coverage detected