mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-05 23:53:21 +00:00
* Do not persist client creds on logout * Override refreshing token flow with re-authentication flow * Update jslib * PR review comments
30 lines
767 B
TypeScript
30 lines
767 B
TypeScript
import {
|
|
deletePassword,
|
|
getPassword,
|
|
setPassword,
|
|
} from 'keytar';
|
|
|
|
import { StorageService } from 'jslib-common/abstractions/storage.service';
|
|
|
|
export class KeytarSecureStorageService implements StorageService {
|
|
constructor(private serviceName: string) { }
|
|
|
|
get<T>(key: string): Promise<T> {
|
|
return getPassword(this.serviceName, key).then(val => {
|
|
return JSON.parse(val) as T;
|
|
});
|
|
}
|
|
|
|
async has(key: string): Promise<boolean> {
|
|
return (await this.get(key)) != null;
|
|
}
|
|
|
|
save(key: string, obj: any): Promise<any> {
|
|
return setPassword(this.serviceName, key, JSON.stringify(obj));
|
|
}
|
|
|
|
remove(key: string): Promise<any> {
|
|
return deletePassword(this.serviceName, key);
|
|
}
|
|
}
|