in src/js/background/background.js [76:105]
async function patchMaskInfo(method = "PATCH", id, data, opts=null) {
const { relayApiSource } = await browser.storage.local.get("relayApiSource");
const relayApiUrlRelayAddressId = `${relayApiSource}/relayaddresses/${id}/`;
const relayApiUrlPatchAddressId = `${relayApiSource}/domainaddresses/${id}/`;
const csrfCookieValue = await browser.storage.local.get("csrfCookieValue");
const headers = new Headers();
headers.set("X-CSRFToken", csrfCookieValue);
headers.set("Content-Type", "application/json");
headers.set("Accept", "application/json");
if (opts && opts.auth) {
const apiToken = await browser.storage.local.get("apiToken");
headers.set("Authorization", `Token ${apiToken.apiToken}`);
}
// Check which type of mask this is: Custom or Random
const apiRequestUrl = opts.mask_type === "custom" ? relayApiUrlPatchAddressId : relayApiUrlRelayAddressId;
const response = await fetch(apiRequestUrl, {
mode: "same-origin",
method,
headers: headers,
body: JSON.stringify(data),
});
return await response.json();
}