keytar storage listener
This commit is contained in:
parent
6e6dc422ac
commit
990c9a4c5d
|
@ -90,6 +90,12 @@
|
|||
"integrity": "sha512-clg9raJTY0EOo5pVZKX3ZlMjlYzVU73L71q5OV1jhE2Uezb7oF94jh4CvwrW6wInquQAdhOxJz5VDF2TLUGmmA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/keytar": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/keytar/-/keytar-4.0.1.tgz",
|
||||
"integrity": "sha512-loKBID6UL4QjhD2scuvv6oAPlQ/WAY7aYTDyKlKo7fIgriLS8EZExqT567cHL5CY6si51MRoX1+r3mitD3eYrA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/lunr": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.1.5.tgz",
|
||||
|
@ -5164,6 +5170,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"keytar": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/keytar/-/keytar-4.1.0.tgz",
|
||||
"integrity": "sha512-L3KqiSMtpVitlug4uuI+K5XLne9SAVEFWE8SCQIhQiH0IA/CTbon5v5prVLKK0Ken54o2O8V9HceKagpwJum+Q==",
|
||||
"requires": {
|
||||
"nan": "2.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"nan": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.5.1.tgz",
|
||||
"integrity": "sha1-1bAWkSUzJql6K77p5hxV2NYDUeI="
|
||||
}
|
||||
}
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/jasmine": "^2.8.2",
|
||||
"@types/keytar": "^4.0.1",
|
||||
"@types/lunr": "2.1.5",
|
||||
"@types/node": "8.0.19",
|
||||
"@types/node-forge": "0.7.1",
|
||||
|
@ -65,6 +66,7 @@
|
|||
"core-js": "2.4.1",
|
||||
"electron-log": "2.2.14",
|
||||
"electron-store": "1.3.0",
|
||||
"keytar": "4.1.0",
|
||||
"lunr": "2.1.6",
|
||||
"node-forge": "0.7.1",
|
||||
"rxjs": "5.5.6",
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import { ipcMain } from 'electron';
|
||||
|
||||
import {
|
||||
deletePassword,
|
||||
getPassword,
|
||||
setPassword,
|
||||
} from 'keytar';
|
||||
|
||||
export class KeytarStorageListener {
|
||||
constructor(private serviceName: string) { }
|
||||
|
||||
init() {
|
||||
ipcMain.on('keytar', async (event: any, message: any) => {
|
||||
try {
|
||||
let val: string = null;
|
||||
if (message.action && message.key) {
|
||||
if (message.action === 'getPassword') {
|
||||
val = await getPassword(this.serviceName, message.key);
|
||||
} else if (message.action === 'setPassword' && message.value) {
|
||||
await setPassword(this.serviceName, message.key, message.value);
|
||||
} else if (message.action === 'deletePassword') {
|
||||
await deletePassword(this.serviceName, message.key);
|
||||
}
|
||||
}
|
||||
|
||||
event.returnValue = val;
|
||||
} catch {
|
||||
event.returnValue = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue