1
0
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:
addison
2021-11-01 12:35:27 -04:00
parent 1bd968a023
commit 4f71c1832c
5 changed files with 31 additions and 14 deletions

View File

@@ -1,12 +1,9 @@
import { StorageOptions } from '../models/domain/storageOptions';
export abstract class StorageService {
get: <T>(key: string, options?: StorageServiceOptions) => Promise<T>;
has: (key: string, options?: StorageServiceOptions) => Promise<boolean>;
save: (key: string, obj: any, options?: StorageServiceOptions) => Promise<any>;
remove: (key: string, options?: StorageServiceOptions) => Promise<any>;
get: <T>(key: string, options?: StorageOptions) => Promise<T>;
has: (key: string, options?: StorageOptions) => Promise<boolean>;
save: (key: string, obj: any, options?: StorageOptions) => Promise<any>;
remove: (key: string, options?: StorageOptions) => Promise<any>;
}
export interface StorageServiceOptions {
keySuffix: KeySuffixOptions;
}
export type KeySuffixOptions = 'auto' | 'biometric';

View File

@@ -0,0 +1,4 @@
export enum KeySuffixOptions {
Auto = 'auto',
Biometric = 'biometric',
}

View File

@@ -0,0 +1,5 @@
export enum StorageLocation {
Both = 'both',
Disk = 'disk',
Memory = 'memory',
}

View File

@@ -0,0 +1,9 @@
import { KeySuffixOptions } from '../../enums/keySuffixOptions';
import { StorageLocation } from '../../enums/storageLocation';
export type StorageOptions = {
keySuffix?: KeySuffixOptions;
storageLocation?: StorageLocation;
useSecureStorage?: boolean;
userId?: string;
};