function init () {
  // attempt to refresh credentials from active session

  let idToken
  let diff = 0

  try {
    idToken = window.localStorage.getItem(cognitoUserPoolId)
    if (idToken) diff = getRemainingSessionTime(idToken)
  } catch (error) {
    console.error(error)
  }

  if (diff > 0) {
    store.idToken = idToken
    logoutTimer = setTimeout(logout, diff)
    setCredentials()
  } else {
    initApiGatewayClient() // init a blank client (will get overwritten if we have creds)
    logout()
  }
}
On page load, look for an active cookie. If it exists and isn't expired, great, use it. Otherwise, clear everything and make sure we're not logged in.