Skip to content

Commit

Permalink
Update TokenStorage to support non async storage (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradel authored Sep 21, 2019
1 parent aa59b99 commit 2af6c19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/client/src/token-storage-local.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { TokenStorage } from './types';

export const tokenStorageLocal: TokenStorage = {
async setItem(key: string, value: string): Promise<void> {
setItem(key: string, value: string): void {
return localStorage.setItem(key, value);
},

async getItem(key: string): Promise<string | null> {
getItem(key: string): string | null {
return localStorage.getItem(key);
},

async removeItem(key: string): Promise<void> {
removeItem(key: string): void {
return localStorage.removeItem(key);
},
};
8 changes: 5 additions & 3 deletions packages/client/src/types/token-storage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
type ValueOrPromise<T> = T | Promise<T>;

export interface TokenStorage {
setItem(key: string, value: string): Promise<void>;
getItem(key: string): Promise<string | null>;
removeItem(key: string): Promise<void>;
setItem(key: string, value: string): ValueOrPromise<void>;
getItem(key: string): ValueOrPromise<string | null>;
removeItem(key: string): ValueOrPromise<void>;
}

0 comments on commit 2af6c19

Please sign in to comment.