mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-04 02:29:06 +00:00
Email recovery needs the recovery code from the enrollment email. People who delete their mail lose it, and with it the only way back in. `logicsrc vault recovery enable --assisted` (opt-in) replaces that code with a fresh sign-in: recovery asks for the one-time code emailed at that moment and a confirmation in the browser with a passkey of the account or its connected CoinPay identity (bound by subject, never by email, never creating an account, no session made). - Server: U is kept sealed under VAULT_ESCROW_KEY in vault_recovery_assisted (migration 015) only for accounts that ask. A step-up (vault_recovery_stepups) is single use, lives ten minutes, names no account and is approved only by a proof belonging to the account being recovered. The second proof is checked before the one-time code, so a missing confirmation never spends it. A claim without a confirmed step-up never returns U. disable and a plain re-enroll delete the stored U. - CLI: `passwd --email` and `vault recover --email` print the link, wait for the confirmation, then ask for the one-time code. The re-arm keeps the mode. - This mode is custodial: the server holds everything that opens the vault. docs/opencreds/security.md says so; accounts that do not opt in keep the split-key scheme unchanged. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
/* Vault recovery confirmation: prove it is you with a passkey of the account being
|
|
recovered. Uses the @simplewebauthn/browser UMD bundle (/vendor). */
|
|
(function () {
|
|
var btn = document.getElementById("stepup-passkey");
|
|
var msg = document.getElementById("stepup-msg");
|
|
if (!btn) return;
|
|
var base = "/recover/confirm/" + encodeURIComponent(btn.getAttribute("data-stepup"));
|
|
|
|
function csrf() {
|
|
var m = document.cookie.match(/(?:^|; )mc_csrf=([^;]+)/);
|
|
return m ? decodeURIComponent(m[1]) : "";
|
|
}
|
|
function post(url, body) {
|
|
return fetch(url, {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json", "x-csrf-token": csrf() },
|
|
body: JSON.stringify(body || {}),
|
|
});
|
|
}
|
|
function say(t) { if (msg) msg.textContent = t; }
|
|
|
|
btn.addEventListener("click", async function () {
|
|
btn.disabled = true;
|
|
say("Waiting for your passkey…");
|
|
try {
|
|
var optsRes = await post(base + "/passkey/options");
|
|
var opts = await optsRes.json();
|
|
if (!optsRes.ok) throw new Error(opts.error || "Could not start.");
|
|
var asr = await SimpleWebAuthnBrowser.startAuthentication({ optionsJSON: opts });
|
|
var r = await post(base + "/passkey/verify", asr);
|
|
var out = await r.json();
|
|
if (!r.ok || !out.ok) throw new Error(out.error || "The passkey did not verify.");
|
|
location.reload();
|
|
} catch (e) {
|
|
say(e && e.message ? e.message : "Could not confirm with a passkey.");
|
|
btn.disabled = false;
|
|
}
|
|
});
|
|
})();
|