From 2af6c19df71f6245bf0a460c3dad45c49a1708c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Pradel?= Date: Sat, 21 Sep 2019 22:11:45 +0200 Subject: [PATCH] Update TokenStorage to support non async storage (#810) --- packages/client/src/token-storage-local.ts | 6 +++--- packages/client/src/types/token-storage.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/client/src/token-storage-local.ts b/packages/client/src/token-storage-local.ts index 7f4c78ea9..7fd25dafe 100644 --- a/packages/client/src/token-storage-local.ts +++ b/packages/client/src/token-storage-local.ts @@ -1,15 +1,15 @@ import { TokenStorage } from './types'; export const tokenStorageLocal: TokenStorage = { - async setItem(key: string, value: string): Promise { + setItem(key: string, value: string): void { return localStorage.setItem(key, value); }, - async getItem(key: string): Promise { + getItem(key: string): string | null { return localStorage.getItem(key); }, - async removeItem(key: string): Promise { + removeItem(key: string): void { return localStorage.removeItem(key); }, }; diff --git a/packages/client/src/types/token-storage.ts b/packages/client/src/types/token-storage.ts index d99145680..1c5bcaf79 100644 --- a/packages/client/src/types/token-storage.ts +++ b/packages/client/src/types/token-storage.ts @@ -1,5 +1,7 @@ +type ValueOrPromise = T | Promise; + export interface TokenStorage { - setItem(key: string, value: string): Promise; - getItem(key: string): Promise; - removeItem(key: string): Promise; + setItem(key: string, value: string): ValueOrPromise; + getItem(key: string): ValueOrPromise; + removeItem(key: string): ValueOrPromise; }