1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-20 06:56:40 +02:00

changed ipc method naming convention

This commit is contained in:
antelle 2021-01-30 18:39:25 +01:00
parent e13002bab3
commit 1fa0eebc3b
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
5 changed files with 45 additions and 37 deletions

View File

@ -36,7 +36,7 @@ if (Launcher) {
}
},
'yk-chal-resp-result'({ callbackId, error, result }) {
yubiKeyChallengeResponseResult({ callbackId, error, result }) {
const callback = ykChalRespCallbacks[callbackId];
if (callback) {
const willBeCalledAgain = error && error.touchRequested;
@ -170,29 +170,29 @@ if (Launcher) {
},
startUsbListener() {
this.call('start-usb');
this.call('startUsbListener');
this.usbListenerRunning = true;
},
stopUsbListener() {
this.usbListenerRunning = false;
if (host) {
this.call('stop-usb');
this.call('stopUsbListener');
}
},
getYubiKeys(config) {
return this.call('get-yubikeys', config);
return this.call('getYubiKeys', config);
},
yubiKeyChallengeResponse(yubiKey, challenge, slot, callback) {
ykChalRespCallbacks[callId] = callback;
return this.call('yk-chal-resp', yubiKey, challenge, slot, callId);
return this.call('yubiKeyChallengeResponse', yubiKey, challenge, slot, callId);
},
yubiKeyCancelChallengeResponse() {
if (host) {
this.call('yk-cancel-chal-resp');
this.call('yubiKeyCancelChallengeResponse');
}
},
@ -203,51 +203,55 @@ if (Launcher) {
hardwareEncrypt: async (value) => {
const { ipcRenderer } = Launcher.electron();
value = NativeModules.makeXoredValue(value);
const encrypted = await ipcRenderer.invoke('hardware-encrypt', value);
const encrypted = await ipcRenderer.invoke('hardwareEncrypt', value);
return NativeModules.readXoredValue(encrypted);
},
hardwareDecrypt: async (value, touchIdPrompt) => {
const { ipcRenderer } = Launcher.electron();
value = NativeModules.makeXoredValue(value);
const decrypted = await ipcRenderer.invoke('hardware-decrypt', value, touchIdPrompt);
const decrypted = await ipcRenderer.invoke('hardwareDecrypt', value, touchIdPrompt);
return NativeModules.readXoredValue(decrypted);
},
kbdGetActiveWindow(options) {
return this.call('kbd-get-active-window', options);
return this.call('kbdGetActiveWindow', options);
},
kbdGetActivePid() {
return this.call('kbd-get-active-pid');
return this.call('kbdGetActivePid');
},
kbdShowWindow(win) {
return this.call('kbd-show-window', win);
return this.call('kbdShowWindow', win);
},
kbdText(str) {
return this.call('kbd-text', str);
return this.call('kbdText', str);
},
kbdKeyPress(code, modifiers) {
return this.call('kbd-key-press', code, modifiers);
return this.call('kbdKeyPress', code, modifiers);
},
kbdShortcut(code, modifiers) {
return this.call('kbd-shortcut', code, modifiers);
return this.call('kbdShortcut', code, modifiers);
},
kbdKeyMoveWithCode(down, code, modifiers) {
return this.call('kbd-key-move-with-code', down, code, modifiers);
return this.call('kbdKeyMoveWithCode', down, code, modifiers);
},
kbdKeyMoveWithModifier(down, modifiers) {
return this.call('kbd-key-move-with-modifier', down, modifiers);
return this.call('kbdKeyMoveWithModifier', down, modifiers);
},
kbdKeyMoveWithCharacter(down, character, code, modifiers) {
return this.call('kbd-key-move-with-character', down, character, code, modifiers);
return this.call('kbdKeyMoveWithCharacter', down, character, code, modifiers);
},
ensureModifierNotPressed() {
return this.call('kbdEnsureModifierNotPressed');
}
};

View File

@ -9,7 +9,7 @@ let autoType;
startListener();
const messageHandlers = {
'start-usb'() {
startUsbListener() {
if (usbListenerRunning) {
return;
}
@ -26,7 +26,7 @@ const messageHandlers = {
usbListenerRunning = true;
},
'stop-usb'() {
stopUsbListener() {
if (!usbListenerRunning) {
return;
}
@ -42,7 +42,7 @@ const messageHandlers = {
attachedYubiKeys.length = 0;
},
'get-yubikeys'(config) {
getYubiKeys(config) {
return new Promise((resolve, reject) => {
const ykChapResp = reqNative('yubikey-chalresp');
ykChapResp.getYubiKeys(config, (err, yubiKeys) => {
@ -55,7 +55,7 @@ const messageHandlers = {
});
},
'yk-chal-resp'(yubiKey, challenge, slot, callbackId) {
yubiKeyChallengeResponse(yubiKey, challenge, slot, callbackId) {
const ykChalResp = reqNative('yubikey-chalresp');
challenge = Buffer.from(challenge);
ykChalResp.challengeResponse(yubiKey, challenge, slot, (error, result) => {
@ -70,11 +70,11 @@ const messageHandlers = {
if (result) {
result = [...result];
}
return callback('yk-chal-resp-result', { callbackId, error, result });
return callback('yubiKeyChallengeResponseResult', { callbackId, error, result });
});
},
'yk-cancel-chal-resp'() {
yubiKeyCancelChallengeResponse() {
const ykChalResp = reqNative('yubikey-chalresp');
ykChalResp.cancelChallengeResponse();
},
@ -103,40 +103,44 @@ const messageHandlers = {
});
},
'kbd-get-active-window'(options) {
kbdGetActiveWindow(options) {
return getAutoType().activeWindow(options);
},
'kbd-get-active-pid'() {
kbdGetActivePid() {
return getAutoType().activePid();
},
'kbd-show-window'(win) {
kbdShowWindow(win) {
return getAutoType().showWindow(win);
},
'kbd-text'(str) {
kbdText(str) {
return getAutoType().text(str);
},
'kbd-key-press'(code, modifiers) {
kbdKeyPress(code, modifiers) {
return getAutoType().keyPress(kbdKeyCode(code), kbdModifier(modifiers));
},
'kbd-shortcut'(code) {
kbdShortcut(code) {
return getAutoType().shortcut(kbdKeyCode(code));
},
'kbd-key-move-with-code'(down, code, modifiers) {
kbdKeyMoveWithCode(down, code, modifiers) {
return getAutoType().keyMoveWithCode(down, kbdKeyCode(code), kbdModifier(modifiers));
},
'kbd-key-move-with-modifier'(down, modifiers) {
kbdKeyMoveWithModifier(down, modifiers) {
return getAutoType().keyMoveWithModifier(down, kbdModifier(modifiers));
},
'kbd-key-move-with-character'(down, character, code, modifiers) {
kbdKeyMoveWithCharacter(down, character, code, modifiers) {
return getAutoType().keyMoveWithCharacter(down, character, code, kbdModifier(modifiers));
},
kbdEnsureModifierNotPressed() {
return getAutoType().ensureModifierNotPressed();
}
};

View File

@ -2,6 +2,6 @@ const { ipcMain } = require('electron');
const { hardwareEncrypt, hardwareDecrypt } = require('./ipc-handlers/hardware-crypto');
module.exports.setupIpcHandlers = () => {
ipcMain.handle('hardware-encrypt', hardwareEncrypt);
ipcMain.handle('hardware-decrypt', hardwareDecrypt);
ipcMain.handle('hardwareEncrypt', hardwareEncrypt);
ipcMain.handle('hardwareDecrypt', hardwareDecrypt);
};

4
package-lock.json generated
View File

@ -1982,8 +1982,8 @@
}
},
"@keeweb/keeweb-native-modules": {
"version": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.4/keeweb-native-modules.tgz",
"integrity": "sha512-IGTr/DmZ5wDN0PPSfJ48EEz5srknq2n2Fl4WF9qcCLLEZXa3S/Q56lSV9eRzIvJqwRwM6OCKasPTvJyFAuV34g=="
"version": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.5/keeweb-native-modules.tgz",
"integrity": "sha512-vj4bM0I2oA3A5FWnISM61Fbz8I3DSOX7+Qm0ekRzCNCzy/MxTgTqZeiCLWq7YmdEFuNAu70cI6RCSDgFKBZZJg=="
},
"@sindresorhus/is": {
"version": "0.14.0",

View File

@ -16,7 +16,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/preset-env": "^7.12.7",
"@fortawesome/fontawesome-free": "^5.15.1",
"@keeweb/keeweb-native-modules": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.4/keeweb-native-modules.tgz",
"@keeweb/keeweb-native-modules": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.7.5/keeweb-native-modules.tgz",
"adm-zip": "^0.5.1",
"argon2-browser": "1.15.2",
"autoprefixer": "^10.0.4",