generated from napi-rs/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeytar.js
26 lines (21 loc) · 814 Bytes
/
keytar.js
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
const { AsyncEntry, findCredentialsAsync } = require('./index.js')
module.exports.getPassword = function getPassword(service, account) {
const entry = new AsyncEntry(service, account)
return entry.getPassword()
}
module.exports.setPassword = function setPassword(service, account, password) {
const entry = new AsyncEntry(service, account)
return entry.setPassword(password)
}
module.exports.deletePassword = function deletePassword(service, account) {
const entry = new AsyncEntry(service, account)
return entry.deletePassword()
}
module.exports.findPassword = async function findPassword(service) {
const credentials = await findCredentialsAsync(service)
if (!credentials.length) {
return null
}
return credentials[0].password
}
module.exports.findCredentials = findCredentialsAsync