mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 04:50:52 +00:00
* feat(ssh): restore FIDO2 security key support (#2308) Consolidate the restored feature and its review fixes before rebasing onto current main. Original PR head: 5d0a0c6c9a550364d3ec5c2331395cedfc9ea7ae. * fix(ssh): verify and repair FIDO authentication with simulated hardware Preserve complete OpenSSH SK signature payloads, classify combined PIN/presence prompts correctly, expand IdentityFile tokens, retain certificate selectors, and route shared-agent signing prompts to their originating window. Dismiss prompts when notification helpers exit. Add a software SK provider and opt-in real OpenSSH integration coverage for both algorithms, certificates, SFTP, forwarding, and concurrent windows. * refactor(ui): refine security key forms and authentication motion Use shared Select and Switch controls, concise localized copy and compact token-based dialogs. Add scoped enter/exit, field transition and presence animations with reduced-motion support. Preserve raw prompt details and visible PIN errors. * fix(ssh): align security key prompts with hardware presence and verify Docker logins * fix(ui): keep security key dialog above its remounted overlay * fix: address Codex review on PR #2823 * feat(ssh): guide security key recovery and explicit authentication fallback * test(ssh): exercise security key authentication on native Windows * test(ssh): verify Windows fixture signatures and explicit fallback * test(ssh): configure Windows OpenSSH toolchain and document coverage --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com>
50 lines
2.0 KiB
JavaScript
50 lines
2.0 KiB
JavaScript
"use strict";
|
|
|
|
const prompts = require("./fidoPromptHandler.cjs");
|
|
|
|
function failureReason(context) {
|
|
if (context.timedOut) return "timeout";
|
|
if (context.helperError === 60) return "device-unavailable";
|
|
if (context.helperError === 43 && context.pinSubmitted) return "pin-failed";
|
|
return "failed";
|
|
}
|
|
|
|
function cancelledError() {
|
|
const error = new Error("Security key authentication cancelled.");
|
|
error.code = "ERR_FIDO_CANCELLED";
|
|
return error;
|
|
}
|
|
|
|
async function signWithRecovery(context, options, sign) {
|
|
context.keyName = options.keyLabel || "";
|
|
context.allowPasswordFallback = Boolean(options.password);
|
|
for (;;) {
|
|
if (context.controller.signal.aborted) return { error: cancelledError() };
|
|
context.helperError = null;
|
|
context.pinSubmitted = false;
|
|
context.cancelled = false;
|
|
context.timedOut = false;
|
|
context.attemptController = new AbortController();
|
|
const result = await new Promise(resolve => {
|
|
try { sign((error, signature) => resolve({ error, signature })); }
|
|
catch (error) { resolve({ error }); }
|
|
});
|
|
context.attemptController.abort();
|
|
if (context.cancelled || context.controller.signal.aborted) return { error: cancelledError() };
|
|
if (!result.error && !context.timedOut) return result;
|
|
if (context.timedOut) result.error = new Error("Security key operation timed out");
|
|
const sender = options.resolveWebContents?.();
|
|
if (!sender || sender.isDestroyed?.()) return { error: cancelledError() };
|
|
const response = await prompts.requestFidoPrompt(sender, {
|
|
kind: "recovery", reason: failureReason(context), keyName: context.keyName,
|
|
allowPasswordFallback: context.allowPasswordFallback, leaseId: context.leaseId,
|
|
signal: context.controller.signal,
|
|
});
|
|
if (response?.response === "retry") continue;
|
|
if (response?.response === "fallback" && context.allowPasswordFallback) return result;
|
|
return { error: cancelledError() };
|
|
}
|
|
}
|
|
|
|
module.exports = { signWithRecovery, failureReason, cancelledError };
|