import { deletePassword, getPassword, setPassword, } from 'keytar'; import { StorageService } from 'jslib-common/abstractions/storage.service'; export class KeytarSecureStorageService implements StorageService { constructor(private serviceName: string) { } get(key: string): Promise { return getPassword(this.serviceName, key).then(val => { return JSON.parse(val) as T; }); } async has(key: string): Promise { return (await this.get(key)) != null; } save(key: string, obj: any): Promise { return setPassword(this.serviceName, key, JSON.stringify(obj)); } remove(key: string): Promise { return deletePassword(this.serviceName, key); } }