mirror of
https://github.com/bitwarden/jslib
synced 2026-01-06 18:43:14 +00:00
[refactor] Extract, rename, and expand StorageServiceOptions
* Pulled StorageServiceOptions into its own file * Renamed StorageServiceOptions to StorageOptions * Pulled KeySuffixOpptions into its own file * Converted KeySuffixOptions into an enum from a union type
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
|
||||
import { StorageService, StorageServiceOptions } from 'jslib-common/abstractions/storage.service';
|
||||
import { StorageService } from 'jslib-common/abstractions/storage.service';
|
||||
|
||||
import { StorageOptions } from 'jslib-common/models/domain/storageOptions';
|
||||
|
||||
export class ElectronRendererSecureStorageService implements StorageService {
|
||||
async get<T>(key: string, options?: StorageServiceOptions): Promise<T> {
|
||||
async get<T>(key: string, options?: StorageOptions): Promise<T> {
|
||||
const val = ipcRenderer.sendSync('keytar', {
|
||||
action: 'getPassword',
|
||||
key: key,
|
||||
@@ -12,7 +14,7 @@ export class ElectronRendererSecureStorageService implements StorageService {
|
||||
return Promise.resolve(val != null ? JSON.parse(val) as T : null);
|
||||
}
|
||||
|
||||
async has(key: string, options?: StorageServiceOptions): Promise<boolean> {
|
||||
async has(key: string, options?: StorageOptions): Promise<boolean> {
|
||||
const val = ipcRenderer.sendSync('keytar', {
|
||||
action: 'hasPassword',
|
||||
key: key,
|
||||
@@ -21,7 +23,7 @@ export class ElectronRendererSecureStorageService implements StorageService {
|
||||
return Promise.resolve(!!val);
|
||||
}
|
||||
|
||||
async save(key: string, obj: any, options?: StorageServiceOptions): Promise<any> {
|
||||
async save(key: string, obj: any, options?: StorageOptions): Promise<any> {
|
||||
ipcRenderer.sendSync('keytar', {
|
||||
action: 'setPassword',
|
||||
key: key,
|
||||
@@ -31,7 +33,7 @@ export class ElectronRendererSecureStorageService implements StorageService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async remove(key: string, options?: StorageServiceOptions): Promise<any> {
|
||||
async remove(key: string, options?: StorageOptions): Promise<any> {
|
||||
ipcRenderer.sendSync('keytar', {
|
||||
action: 'deletePassword',
|
||||
key: key,
|
||||
|
||||
Reference in New Issue
Block a user