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,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';
|
||||
|
||||
4
common/src/enums/keySuffixOptions.ts
Normal file
4
common/src/enums/keySuffixOptions.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export enum KeySuffixOptions {
|
||||
Auto = 'auto',
|
||||
Biometric = 'biometric',
|
||||
}
|
||||
5
common/src/enums/storageLocation.ts
Normal file
5
common/src/enums/storageLocation.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum StorageLocation {
|
||||
Both = 'both',
|
||||
Disk = 'disk',
|
||||
Memory = 'memory',
|
||||
}
|
||||
9
common/src/models/domain/storageOptions.ts
Normal file
9
common/src/models/domain/storageOptions.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user