/* * SKYNET SSO * Copyright (C) 2026 Jimmy Galland * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the COPYING file for the full license text. */ const homeUrl = document.getElementById("homeUrl"); const issuer = document.getElementById("issuer"); const hosts = document.getElementById("hosts"); const showNotch = document.getElementById("showNotch"); const result = document.getElementById("result"); browser.storage.local.get({ homeUrl: "https://home.domain.net", issuer: "https://auth.domain.net", protectedHosts: ["domain.net", "domain2.net"], showNotch: true }).then(cfg => { homeUrl.value = cfg.homeUrl; issuer.value = cfg.issuer; hosts.value = cfg.protectedHosts.join("\n"); showNotch.checked = cfg.showNotch !== false; }); document.getElementById("save").addEventListener("click", async () => { const value = issuer.value.trim().replace(/\/$/, ""); if (!/^https:\/\//i.test(value)) { result.textContent = "L’URL doit commencer par https://"; return; } const domains = [ ...new Set( hosts.value .split(/[\r\n,;]+/) .map(value => value.trim().toLowerCase()) .filter(Boolean) ) ]; if ( !domains.length || domains.some(domain => /[\s/:?#]/.test(domain)) ) { result.textContent = "Vérifiez la liste des domaines."; return; } const home = homeUrl.value.trim(); if (!/^https?:\/\//i.test(home)) { result.textContent = "L’URL de la page d’accueil doit commencer par http:// ou https://"; return; } await browser.storage.local.set({ homeUrl: home, issuer: value, protectedHosts: domains, showNotch: showNotch.checked }); result.textContent = "Paramètres enregistrés."; });