L4: generate per-install EIP-6963 provider UUID
Replace the hardcoded UUID with a per-install UUID generated via crypto.randomUUID() and persisted in chrome.storage.local. The content script sends the UUID to the inpage script via postMessage, which updates providerInfo and re-announces the provider.
This commit is contained in:
@@ -156,7 +156,7 @@
|
||||
);
|
||||
|
||||
const providerInfo = {
|
||||
uuid: "f3c5b2a1-8d4e-4f6a-9c7b-1e2d3a4b5c6d",
|
||||
uuid: crypto.randomUUID(),
|
||||
name: "AutistMask",
|
||||
icon: ICON_SVG,
|
||||
rdns: "berlin.sneak.autistmask",
|
||||
@@ -170,6 +170,15 @@
|
||||
);
|
||||
}
|
||||
|
||||
// Accept a stable per-install UUID from the content script.
|
||||
// Re-announce with the updated providerInfo so dApps see the correct UUID.
|
||||
window.addEventListener("message", (event) => {
|
||||
if (event.source !== window) return;
|
||||
if (event.data?.type !== "AUTISTMASK_PROVIDER_UUID") return;
|
||||
providerInfo.uuid = event.data.uuid;
|
||||
announceProvider();
|
||||
});
|
||||
|
||||
window.addEventListener("eip6963:requestProvider", announceProvider);
|
||||
announceProvider();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user