mirror of
https://github.com/morgan9e/virtual-webauthn
synced 2026-04-14 00:04:09 +09:00
19 lines
725 B
JavaScript
19 lines
725 B
JavaScript
const s = document.createElement("script");
|
|
s.src = chrome.runtime.getURL("inject.js");
|
|
s.onload = () => s.remove();
|
|
(document.documentElement || document.head).appendChild(s);
|
|
|
|
window.addEventListener("message", async (event) => {
|
|
if (event.source !== window || event.data?.type !== "VWEBAUTHN_REQUEST") return;
|
|
|
|
const { id, action, payload } = event.data;
|
|
try {
|
|
const response = await chrome.runtime.sendMessage({
|
|
type: "VWEBAUTHN_REQUEST", action, payload,
|
|
});
|
|
window.postMessage({ type: "VWEBAUTHN_RESPONSE", id, ...response }, "*");
|
|
} catch (error) {
|
|
window.postMessage({ type: "VWEBAUTHN_RESPONSE", id, success: false, error: error.message }, "*");
|
|
}
|
|
});
|