mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 13:01:24 +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>
107 lines
3.4 KiB
JavaScript
107 lines
3.4 KiB
JavaScript
"use strict";
|
|
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const {
|
|
classifyAskpassPrompt,
|
|
requestFidoPrompt,
|
|
cancelFidoPromptRequestsForLease,
|
|
handleResponse,
|
|
getRequests,
|
|
} = require("./fidoPromptHandler.cjs");
|
|
|
|
test("classifyAskpassPrompt maps OpenSSH sk-helper prompts", () => {
|
|
assert.equal(classifyAskpassPrompt("Enter PIN for authenticator:"), "pin");
|
|
assert.equal(classifyAskpassPrompt("Confirm user presence for key ED25519-SK"), "touch");
|
|
assert.equal(classifyAskpassPrompt("Touch your security key"), "touch");
|
|
assert.equal(classifyAskpassPrompt("请触摸你的安全密钥"), "touch");
|
|
assert.equal(classifyAskpassPrompt("Something unknown"), "pin");
|
|
});
|
|
|
|
test("requestFidoPrompt delivers IPC payload and resolves on respond", async () => {
|
|
const sent = [];
|
|
const sender = {
|
|
id: 42,
|
|
isDestroyed: () => false,
|
|
send: (channel, payload) => sent.push({ channel, payload }),
|
|
};
|
|
|
|
const pending = requestFidoPrompt(sender, {
|
|
kind: "pin",
|
|
message: "Enter PIN for authenticator:",
|
|
keyName: "yubi",
|
|
});
|
|
|
|
assert.equal(sent.length, 1);
|
|
assert.equal(sent[0].channel, "netcatty:fido-prompt-request");
|
|
assert.equal(sent[0].payload.kind, "pin");
|
|
assert.equal(getRequests().size, 1);
|
|
|
|
const requestId = sent[0].payload.requestId;
|
|
const result = handleResponse(
|
|
{ sender: { id: 42 } },
|
|
{ requestId, response: "123456", cancelled: false },
|
|
);
|
|
assert.equal(result.success, true);
|
|
|
|
const resolved = await pending;
|
|
assert.deepEqual(resolved, { response: "123456" });
|
|
assert.equal(getRequests().size, 0);
|
|
});
|
|
|
|
test("requestFidoPrompt cancel path", async () => {
|
|
const sent = [];
|
|
const sender = {
|
|
id: 7,
|
|
isDestroyed: () => false,
|
|
send: (channel, payload) => sent.push({ channel, payload }),
|
|
};
|
|
const pending = requestFidoPrompt(sender, { kind: "touch", message: "Touch key" });
|
|
const requestId = sent[0].payload.requestId;
|
|
handleResponse({ sender: { id: 7 } }, { requestId, cancelled: true });
|
|
const resolved = await pending;
|
|
assert.deepEqual(resolved, { cancelled: true });
|
|
});
|
|
|
|
test("cancelFidoPromptRequestsForLease settles owned prompts and notifies renderer", async () => {
|
|
const sent = [];
|
|
const sender = {
|
|
id: 11,
|
|
isDestroyed: () => false,
|
|
send: (channel, payload) => sent.push({ channel, payload }),
|
|
};
|
|
const pending = requestFidoPrompt(sender, {
|
|
kind: "pin",
|
|
message: "Enter PIN",
|
|
leaseId: "lease-abc",
|
|
});
|
|
const other = requestFidoPrompt(sender, {
|
|
kind: "touch",
|
|
message: "Touch key",
|
|
leaseId: "lease-other",
|
|
});
|
|
const otherRequestId = sent.find((entry) => (
|
|
entry.channel === "netcatty:fido-prompt-request" && entry.payload.kind === "touch"
|
|
)).payload.requestId;
|
|
|
|
assert.equal(cancelFidoPromptRequestsForLease("lease-abc", "lease-released"), 1);
|
|
assert.deepEqual(await pending, { cancelled: true });
|
|
assert.equal(getRequests().size, 1);
|
|
assert.ok(sent.some((entry) => (
|
|
entry.channel === "netcatty:fido-prompt-cancelled"
|
|
&& entry.payload.reason === "lease-released"
|
|
)));
|
|
|
|
handleResponse({ sender: { id: 11 } }, { requestId: otherRequestId, cancelled: true });
|
|
await other;
|
|
});
|
|
|
|
test("combined OpenSSH PIN and user-presence prompts require secret entry", () => {
|
|
for (const algorithm of ["ED25519-SK", "ECDSA-SK"]) {
|
|
assert.equal(
|
|
classifyAskpassPrompt(`Enter PIN and confirm user presence for ${algorithm} key SHA256:test: `),
|
|
"pin",
|
|
);
|
|
}
|
|
});
|