mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 05:13:29 +00:00
* [PM-22785] Initial push with configuration and ipc changes for the configurable autotype keyboard shortcut * [PM-22785] Add messy code with working configurable hotkey * [PM-22785] Add more messy rust code * [PM-22785] Add temp changes with configurable hotkey ui * Add shortcut display to settings * [PM-22785] Logic updates. Ran npm run prettier and lint:fix. * [PM-22785] Add back disableAutotype with refactors. * [PM-22785] Clean up Rust code * [PM-22785] Clean up Rust code v2 * [PM-22785] Add unicode bounds in Rust code * [PM-22785] Update rust code comments * [PM-22785] Add unicode_value byte length check post-encoding * [PM-22785] Extract encoding to a separate function * Various fixes for the autotype setting label * Misc component fixes * Disallow nunmbers and allow Win key * Themify edit shortcut * Change display of Super to Win * Create autotype format method * Autotpe modal cleanup * [PM-22785] Some cleanup * Add unit tests and adjust error handling * [PM-22785] Fix build issues on Mac and Linux * [PM-22785] Linting fix * Remove unused message * [PM-22785] Linting fix * [PM-22785] More linting fix * [PM-22785] Address initial PR comments * [PM-22785] Comment change * [PM-22785] If statement change * [PM-22785] Update with fixes from PR comments * [PM-22785] Update with fixes from PR comments version ? * add unit tests for get_alphabetic_hot_key() * Fix tests * Add missing mock to tests * [PM-22785] Update with small fixes via PR comments --------- Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com> Co-authored-by: neuronull <9162534+neuronull@users.noreply.github.com>
170 lines
4.5 KiB
TypeScript
170 lines
4.5 KiB
TypeScript
import { ipcRenderer } from "electron";
|
|
|
|
import type { autofill } from "@bitwarden/desktop-napi";
|
|
|
|
import { Command } from "../platform/main/autofill/command";
|
|
import { RunCommandParams, RunCommandResult } from "../platform/main/autofill/native-autofill.main";
|
|
|
|
export default {
|
|
runCommand: <C extends Command>(params: RunCommandParams<C>): Promise<RunCommandResult<C>> =>
|
|
ipcRenderer.invoke("autofill.runCommand", params),
|
|
|
|
listenPasskeyRegistration: (
|
|
fn: (
|
|
clientId: number,
|
|
sequenceNumber: number,
|
|
request: autofill.PasskeyRegistrationRequest,
|
|
completeCallback: (
|
|
error: Error | null,
|
|
response: autofill.PasskeyRegistrationResponse,
|
|
) => void,
|
|
) => void,
|
|
) => {
|
|
ipcRenderer.on(
|
|
"autofill.passkeyRegistration",
|
|
(
|
|
event,
|
|
data: {
|
|
clientId: number;
|
|
sequenceNumber: number;
|
|
request: autofill.PasskeyRegistrationRequest;
|
|
},
|
|
) => {
|
|
const { clientId, sequenceNumber, request } = data;
|
|
fn(clientId, sequenceNumber, request, (error, response) => {
|
|
if (error) {
|
|
ipcRenderer.send("autofill.completeError", {
|
|
clientId,
|
|
sequenceNumber,
|
|
error: error.message,
|
|
});
|
|
return;
|
|
}
|
|
|
|
ipcRenderer.send("autofill.completePasskeyRegistration", {
|
|
clientId,
|
|
sequenceNumber,
|
|
response,
|
|
});
|
|
});
|
|
},
|
|
);
|
|
},
|
|
|
|
listenPasskeyAssertion: (
|
|
fn: (
|
|
clientId: number,
|
|
sequenceNumber: number,
|
|
request: autofill.PasskeyAssertionRequest,
|
|
completeCallback: (error: Error | null, response: autofill.PasskeyAssertionResponse) => void,
|
|
) => void,
|
|
) => {
|
|
ipcRenderer.on(
|
|
"autofill.passkeyAssertion",
|
|
(
|
|
event,
|
|
data: {
|
|
clientId: number;
|
|
sequenceNumber: number;
|
|
request: autofill.PasskeyAssertionRequest;
|
|
},
|
|
) => {
|
|
const { clientId, sequenceNumber, request } = data;
|
|
fn(clientId, sequenceNumber, request, (error, response) => {
|
|
if (error) {
|
|
ipcRenderer.send("autofill.completeError", {
|
|
clientId,
|
|
sequenceNumber,
|
|
error: error.message,
|
|
});
|
|
return;
|
|
}
|
|
|
|
ipcRenderer.send("autofill.completePasskeyAssertion", {
|
|
clientId,
|
|
sequenceNumber,
|
|
response,
|
|
});
|
|
});
|
|
},
|
|
);
|
|
},
|
|
listenPasskeyAssertionWithoutUserInterface: (
|
|
fn: (
|
|
clientId: number,
|
|
sequenceNumber: number,
|
|
request: autofill.PasskeyAssertionWithoutUserInterfaceRequest,
|
|
completeCallback: (error: Error | null, response: autofill.PasskeyAssertionResponse) => void,
|
|
) => void,
|
|
) => {
|
|
ipcRenderer.on(
|
|
"autofill.passkeyAssertionWithoutUserInterface",
|
|
(
|
|
event,
|
|
data: {
|
|
clientId: number;
|
|
sequenceNumber: number;
|
|
request: autofill.PasskeyAssertionWithoutUserInterfaceRequest;
|
|
},
|
|
) => {
|
|
const { clientId, sequenceNumber, request } = data;
|
|
fn(clientId, sequenceNumber, request, (error, response) => {
|
|
if (error) {
|
|
ipcRenderer.send("autofill.completeError", {
|
|
clientId,
|
|
sequenceNumber,
|
|
error: error.message,
|
|
});
|
|
return;
|
|
}
|
|
|
|
ipcRenderer.send("autofill.completePasskeyAssertion", {
|
|
clientId,
|
|
sequenceNumber,
|
|
response,
|
|
});
|
|
});
|
|
},
|
|
);
|
|
},
|
|
configureAutotype: (enabled: boolean, keyboardShortcut: string[]) => {
|
|
ipcRenderer.send("autofill.configureAutotype", { enabled, keyboardShortcut });
|
|
},
|
|
listenAutotypeRequest: (
|
|
fn: (
|
|
windowTitle: string,
|
|
completeCallback: (
|
|
error: Error | null,
|
|
response: { username?: string; password?: string },
|
|
) => void,
|
|
) => void,
|
|
) => {
|
|
ipcRenderer.on(
|
|
"autofill.listenAutotypeRequest",
|
|
(
|
|
event,
|
|
data: {
|
|
windowTitle: string;
|
|
},
|
|
) => {
|
|
const { windowTitle } = data;
|
|
|
|
fn(windowTitle, (error, response) => {
|
|
if (error) {
|
|
ipcRenderer.send("autofill.completeError", {
|
|
windowTitle,
|
|
error: error.message,
|
|
});
|
|
return;
|
|
}
|
|
|
|
ipcRenderer.send("autofill.completeAutotypeRequest", {
|
|
windowTitle,
|
|
response,
|
|
});
|
|
});
|
|
},
|
|
);
|
|
},
|
|
};
|