| 35 | } |
| 36 | |
| 37 | class LocalOnlyStorage implements Storage { |
| 38 | get<T>(key: string, ifNotPresent: T): string | T { |
| 39 | try { |
| 40 | return window.localStorage.getItem(prefix + key) ?? ifNotPresent; |
| 41 | } catch { |
| 42 | // Swallow up any security exceptions... |
| 43 | return ifNotPresent; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | remove(key: string) { |
| 48 | try { |
| 49 | window.localStorage.removeItem(prefix + key); |
| 50 | } catch { |
| 51 | // Swallow up any security exceptions... |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | set(key: string, value: string): boolean { |
| 56 | try { |
| 57 | window.localStorage.setItem(prefix + key, value); |
| 58 | return true; |
| 59 | } catch { |
| 60 | // Swallow up any security exceptions... |
| 61 | } |
| 62 | return false; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | export const localStorage = new LocalOnlyStorage(); |
| 67 |
nothing calls this directly
no outgoing calls
no test coverage detected