-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
29 lines (27 loc) · 1.73 KB
/
preload.js
File metadata and controls
29 lines (27 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { contextBridge, ipcRenderer } = require("electron");
// Do not expose Electron APIs to untrusted web content
// https://www.electronjs.org/docs/latest/tutorial/security#20-do-not-expose-electron-apis-to-untrusted-web-content
contextBridge.exposeInMainWorld("gpgAPI", {
// Main Windows APIs
encryptMessage: (privateKeyId, recipient, trustKey, plaintext) =>
ipcRenderer.invoke("encrypt-message", { privateKeyId, recipient, trustKey, plaintext }),
decryptMessage: (ciphertext) =>
ipcRenderer.invoke("decrypt-message", { ciphertext }),
listPublicKeys: () =>
ipcRenderer.invoke("list-public-keys"),
listPrivateKeys: () =>
ipcRenderer.invoke("list-private-keys"),
retrievePublicKey: (keyId) =>
ipcRenderer.invoke("retrieve-public-key", { keyId }),
retrieveSecretKey: (keyId) =>
ipcRenderer.invoke("retrieve-secret-key", { keyId }),
// Edit Key Window APIs
openEditKeyWindow: (keyId) => ipcRenderer.invoke('open-edit-key-window', keyId),
getKeyDetails: (keyId) => ipcRenderer.invoke('get-key-details', keyId),
updateKeyExpiry: (fingerprint, newExpiry) => ipcRenderer.invoke('update-key-expiry', { fingerprint, newExpiry }),
setKeyTrust: (fingerprint, trustId) => ipcRenderer.invoke('set-key-trust', { fingerprint, trustId }),
addSubkey: (keyId) => ipcRenderer.invoke('add-subkey', keyId),
updateSubkeyExpiry: (primaryFingerprint, subkeyFingerprint, newExpiry) => ipcRenderer.invoke('update-subkey-expiry', { primaryFingerprint, subkeyFingerprint, newExpiry }),
revokeSubkey: (subkeyId) => ipcRenderer.invoke('revoke-subkey', subkeyId),
deleteSubkey: (subkeyId) => ipcRenderer.invoke('delete-subkey', subkeyId),
});