Monkeypatch fetch() so OMEMO file downloads work
This commit is contained in:
parent
74d9837402
commit
799cd242f8
27
dist/index.html
vendored
27
dist/index.html
vendored
@ -22,6 +22,31 @@
|
|||||||
<script>
|
<script>
|
||||||
// access the pre-bundled global API functions
|
// access the pre-bundled global API functions
|
||||||
const { invoke } = window.__TAURI__.tauri;
|
const { invoke } = window.__TAURI__.tauri;
|
||||||
|
const { getClient, ResponseType } = window.__TAURI__.http;
|
||||||
|
const tauriFetch = window.__TAURI__.http.fetch;
|
||||||
|
|
||||||
|
const realFetch = window.fetch;
|
||||||
|
|
||||||
|
// this is clearly not a complete fetch implementation
|
||||||
|
// but it's enough for the omemo downloadFile() function...
|
||||||
|
window.fetch = async function(url) {
|
||||||
|
console.log("fetching url: " + url);
|
||||||
|
|
||||||
|
const client = await getClient();
|
||||||
|
let response = await await client.get(
|
||||||
|
url, {
|
||||||
|
timeout: 30,
|
||||||
|
responseType: ResponseType.Binary
|
||||||
|
});
|
||||||
|
|
||||||
|
let data = new Uint8Array(response.data).buffer;
|
||||||
|
|
||||||
|
response.arrayBuffer = async function() {
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
function addCredentials (login, password) {
|
function addCredentials (login, password) {
|
||||||
localStorage.setItem('login', login);
|
localStorage.setItem('login', login);
|
||||||
@ -86,7 +111,7 @@
|
|||||||
message_archiving: 'always',
|
message_archiving: 'always',
|
||||||
play_sounds: false,
|
play_sounds: false,
|
||||||
view_mode: 'fullscreen',
|
view_mode: 'fullscreen',
|
||||||
loglevel: 'debug',
|
//loglevel: 'debug',
|
||||||
muc_respect_autojoin: true,
|
muc_respect_autojoin: true,
|
||||||
muc_show_logs_before_join: true,
|
muc_show_logs_before_join: true,
|
||||||
whitelisted_plugins: ['converse-desktop-credentials']
|
whitelisted_plugins: ['converse-desktop-credentials']
|
||||||
|
@ -12,7 +12,12 @@
|
|||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
"all": true
|
"all": true,
|
||||||
|
"http": {
|
||||||
|
"all": true,
|
||||||
|
"request": true,
|
||||||
|
"scope": ["https://**"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"systemTray": {
|
"systemTray": {
|
||||||
"iconPath": "icons/icon.png",
|
"iconPath": "icons/icon.png",
|
||||||
|
Loading…
Reference in New Issue
Block a user