(action, key, extra = {})
| 970 | `; |
| 971 | |
| 972 | const post = async (action, key, extra = {}) => { |
| 973 | const res = await fetch(withBase('/api/admin/setEncryptionKey.php'), { |
| 974 | method: 'POST', |
| 975 | credentials: 'include', |
| 976 | headers: { |
| 977 | 'Content-Type': 'application/json', |
| 978 | 'X-CSRF-Token': window.csrfToken || '' |
| 979 | }, |
| 980 | body: JSON.stringify({ action, ...(key ? { key } : {}), ...extra }) |
| 981 | }); |
| 982 | const text = await res.text(); |
| 983 | let body = null; |
| 984 | try { body = text ? JSON.parse(text) : null; } catch (e) { /* ignore */ } |
| 985 | return { |
| 986 | ok: res.ok, |
| 987 | status: res.status, |
| 988 | body: body || {}, |
| 989 | raw: text || '' |
| 990 | }; |
| 991 | }; |
| 992 | |
| 993 | const refresh = async () => { |
| 994 | const r = await fetch(withBase('/api/admin/getConfig.php?ts=' + Date.now()), { |
no test coverage detected