-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAuthSettings.js
36 lines (30 loc) · 871 Bytes
/
AuthSettings.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
27
28
29
30
31
32
33
34
35
36
let _instance;
let _secretStorage;
module.exports = class AuthSettings {
constructor(secretStorage) {
_secretStorage = secretStorage;
}
static init(context) {
_instance = new AuthSettings(context.secrets)
}
static get instance(){
return _instance
}
async storeAuthData(key, secret){
if (key && secret) {
await _secretStorage.store(key, secret);
}
}
async getAuthData(key) {
return await _secretStorage.get(key);
}
async deleteAuthData(key) {
try {
await _secretStorage.delete(key);
} catch (error) {
//ignore, usually still worked, testing if it did below
}
var authData = await _instance.getAuthData(key);
return authData === undefined || authData === null || authData === '';
}
}