🔤 Ups docs to current state

This commit is contained in:
2026-06-11 13:24:14 +02:00
parent 656c2da8cf
commit b23974a51f
12 changed files with 121 additions and 6 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);
}