class persist {
  static get SESSION_TOKEN_KEY () { return 'sessionToken' }
  static willGetSessionToken() {
    return new Promise(resolve => {
      try {
        resolve(localStorage && localStorage.getItem(persist.SESSION_TOKEN_KEY))
      } catch (err) {
        resolve(null)
      }
    })
  }

  static willSetSessionToken(sessionToken) {
    return !sessionToken ? persist.willRemoveSessionToken : new Promise(resolve => {
      try {
        localStorage && localStorage.setItem(persist.SESSION_TOKEN_KEY, sessionToken)
      } catch (err) {
        // Ignore
      }
      resolve(sessionToken)
    })
  }

  static willRemoveSessionToken() {
    return new Promise(resolve => {
      try {
        localStorage && localStorage.removeItem(persist.SESSION_TOKEN_KEY)
      } catch (err) {
        // Ignore
      }
      resolve(null)
    })
  }
}

module.exports = persist

const localForage = require('localforage')

class persist {
  static get SESSION_TOKEN_KEY() { return 'sessionToken' }
  static get ACCESS_TOKEN_KEY() { return 'accessToken' }

  static async willGetSessionToken() {
    return localForage.getItem(persist.SESSION_TOKEN_KEY).catch(err => err)
  }

  static async willSetSessionToken(value) {
    return localForage.setItem(persist.SESSION_TOKEN_KEY, value).catch(err => err)
  }

  static async willRemoveSessionToken() {
    return localForage.removeItem(persist.SESSION_TOKEN_KEY).catch(err => err)
  }

  static async willGetAccessToken() {
    return localForage.getItem(persist.ACCESS_TOKEN_KEY).catch(err => err)
  }

  static async willSetAccessToken(value) {
    return localForage.setItem(persist.ACCESS_TOKEN_KEY, value).catch(err => err)
  }

  static async willRemoveAccessToken() {
    return localForage.removeItem(persist.ACCESS_TOKEN_KEY).catch(err => err)
  }
}

module.exports = persist

Use localForage instead of localStorage
feat(client): Use localForage instead of localStorage
