This commit is contained in:
2026-04-24 14:03:17 +02:00
commit 0191347312
31 changed files with 16354 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
export function constructHeaders(username, password) {
const Authorization = constructAuthHeader(username, password);
return {
Authorization,
Accept: "application/json"
};
}
function constructAuthHeader(username, password) {
const credentials = `${username}:${password}`;
return `Basic ${toBase64(credentials)}`;
}
function toBase64(data) {
const existsTextEncoder= typeof TextEncoder !== 'undefined';
if (!existsTextEncoder)
return btoa(data);
const existsUint8ArrayToBase64= typeof Uint8Array.prototype.toBase64 === 'function';
if (existsUint8ArrayToBase64)
return new TextEncoder().encode(data).toBase64();
const binString= Array.from(new TextEncoder().encode(data))
.map(x=> String.fromCharCode(x)).join("");
return btoa(binString);
}