Add browser save and update workflow

This commit is contained in:
Joe Julian
2026-04-23 21:00:29 -07:00
parent 14c9bc72f6
commit f82ddf7435
11 changed files with 683 additions and 52 deletions
+35 -1
View File
@@ -396,6 +396,22 @@ function fillCredential(credential, targetDescriptor) {
return { ok: true };
}
function submittedCredential(candidate, rawURL) {
if (!candidate?.passwordInput) {
return null;
}
const password = String(candidate.passwordInput.value || "").trim();
if (!password) {
return null;
}
return {
title: domainLabel(rawURL),
username: String(candidate.usernameInput?.value || "").trim(),
password,
url: String(rawURL || "").trim()
};
}
function domainLabel(rawURL) {
try {
return new URL(rawURL).host || "";
@@ -447,7 +463,8 @@ const contentTestExports = {
fieldHintText,
scopeHintText,
hasAuthFlowSignals,
authFlowCandidate
authFlowCandidate,
submittedCredential
};
if (isNodeTestEnv) {
@@ -805,6 +822,23 @@ if (isNodeTestEnv) {
scheduleRefresh(false);
}, true);
document.addEventListener("submit", (event) => {
const form = event.target instanceof HTMLFormElement ? event.target : null;
if (!form) {
return;
}
const passwordInput = visibleInputs(form).find(isPasswordCandidate) || null;
const candidate = passwordInput ? authFlowCandidate(passwordInput) : null;
const observed = submittedCredential(candidate, window.location.href);
if (!observed) {
return;
}
void runtimeSend({
type: "keepassgo-observed-login",
observed
}).catch(() => null);
}, true);
document.addEventListener("click", (event) => {
if (!root.contains(event.target)) {
chooserOpen = false;