forked from atom/node-keytar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeytar.js
More file actions
46 lines (35 loc) · 1.05 KB
/
keytar.js
File metadata and controls
46 lines (35 loc) · 1.05 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const keytar = require("pkg-prebuilds")(
__dirname,
require("./binding-options")
);
function checkRequired(val, name) {
if (!val || val.length <= 0) {
throw new Error(name + ' is required.');
}
}
module.exports = {
getPassword: function (service, account) {
checkRequired(service, 'Service')
checkRequired(account, 'Account')
return keytar.getPassword(service, account)
},
setPassword: function (service, account, password) {
checkRequired(service, 'Service')
checkRequired(account, 'Account')
checkRequired(password, 'Password')
return keytar.setPassword(service, account, password)
},
deletePassword: function (service, account) {
checkRequired(service, 'Service')
checkRequired(account, 'Account')
return keytar.deletePassword(service, account)
},
findPassword: function (service) {
checkRequired(service, 'Service')
return keytar.findPassword(service)
},
findCredentials: function (service) {
checkRequired(service, 'Service')
return keytar.findCredentials(service)
}
}