fix(L4): generate EIP-6963 provider UUID at install time

UUID is generated once via crypto.randomUUID(), persisted in
chrome.storage.local, and sent from the content script to the
inpage script via postMessage.
This commit is contained in:
2026-02-27 11:58:19 -08:00
zatwierdzone przez user
rodzic 98f68adb11
commit 04a34d1a5e
2 zmienionych plików z 39 dodań i 7 usunięć
+17
Wyświetl plik
@@ -13,6 +13,23 @@ if (typeof browser !== "undefined") {
(document.head || document.documentElement).appendChild(script);
}
// Send the persisted EIP-6963 provider UUID to the inpage script.
// Generated once at install time and stored in chrome.storage.local.
(function sendProviderUuid() {
const storage =
typeof browser !== "undefined"
? browser.storage.local
: chrome.storage.local;
storage.get("eip6963Uuid", (items) => {
let uuid = items?.eip6963Uuid;
if (!uuid) {
uuid = crypto.randomUUID();
storage.set({ eip6963Uuid: uuid });
}
window.postMessage({ type: "AUTISTMASK_PROVIDER_UUID", uuid }, "*");
});
})();
// Relay requests from the page to the background script
window.addEventListener("message", (event) => {
if (event.source !== window) return;