@data-fair/lib-vue 1.10.4 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/session.js +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.10.4",
3
+ "version": "1.11.0",
4
4
  "description": "Composables and other utilities for Vue applications in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [
package/session.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { FetchError } from 'ofetch'
1
2
  import { reactive, computed, watch, inject, ref } from 'vue'
2
3
  import { ofetch } from 'ofetch'
3
4
  import { jwtDecode } from 'jwt-decode'
@@ -211,8 +212,16 @@ export async function getSession (initOptions) {
211
212
  if (!ssr) {
212
213
  window.localStorage.setItem('sd-keepalive' + options.sitePath, `${new Date().getTime()}`)
213
214
  }
214
- await customFetch(`${options.directoryUrl}/api/auth/keepalive`, { method: 'POST' })
215
- readState()
215
+ try {
216
+ await customFetch(`${options.directoryUrl}/api/auth/keepalive`, { method: 'POST' })
217
+ } catch (err) {
218
+ if (err instanceof FetchError && err.statusCode === 401) {
219
+ // this is expected if the session was deleted server side
220
+ } else {
221
+ throw err
222
+ }
223
+ readState()
224
+ }
216
225
  }
217
226
  const refreshSiteInfo = async () => {
218
227
  const siteInfo = await customFetch(`${options.directoryUrl}/api/sites/_public`) ?? null