Created
November 16, 2020 10:05
-
-
Save oleh-zaporozhets/fc8d62f1a9f6ce0189a96b637cc2106f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Storage from './storage'; | |
| enum Locals { | |
| ACCESS_TOKEN = 'access_token', | |
| REFRESH_TOKEN = 'refresh_token' | |
| } | |
| export default class Tokens extends Storage<Locals> { | |
| private static instance?: Tokens; | |
| private constructor() { | |
| super(); | |
| } | |
| public static getInstance() { | |
| if (!this.instance) { | |
| this.instance = new Tokens(); | |
| } | |
| return this.instance; | |
| } | |
| public getAccessToken() { | |
| return this.get(Locals.ACCESS_TOKEN); | |
| } | |
| public setAccessToken(accessToken: string) { | |
| this.set(Locals.ACCESS_TOKEN, accessToken); | |
| } | |
| public getRefreshToken() { | |
| return this.get(Locals.REFRESH_TOKEN); | |
| } | |
| public setRefreshToken(refreshToken: string) { | |
| this.set(Locals.REFRESH_TOKEN, refreshToken); | |
| } | |
| public clear() { | |
| this.clearItems([Locals.ACCESS_TOKEN, Locals.REFRESH_TOKEN]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment