@dargmuesli/nuxt-vio 3.4.0 → 3.5.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.
@@ -1,11 +1,10 @@
1
1
  import { Dayjs } from 'dayjs'
2
2
 
3
3
  export const useDateTime = () => {
4
- const event = useRequestEvent()
5
- const { $dayjs } = useNuxtApp()
4
+ const { $dayjs, ssrContext } = useNuxtApp()
6
5
  const timezoneCookie = useCookie(TIMEZONE_COOKIE_NAME)
7
6
 
8
- const timezoneHeader = event?.node.req.headers[TIMEZONE_HEADER_KEY]
7
+ const timezoneHeader = ssrContext?.event.node.req.headers[TIMEZONE_HEADER_KEY]
9
8
  const timezone =
10
9
  timezoneHeader && !Array.isArray(timezoneHeader)
11
10
  ? timezoneHeader
@@ -1,8 +1,8 @@
1
1
  export const useHost = () => {
2
- if (process.server) {
3
- const event = useRequestEvent()
2
+ const { ssrContext } = useNuxtApp()
4
3
 
5
- return getHost(event.node.req)
4
+ if (ssrContext) {
5
+ return getHost(ssrContext.event)
6
6
  } else {
7
7
  return location.host
8
8
  }
@@ -1,6 +1,9 @@
1
+ import { POLYFILLS } from '../utils/constants'
2
+
1
3
  export const usePolyfills = () => {
2
- const polyfills =
3
- 'https://polyfill.io/v3/polyfill.min.js?features=Promise&flags=gated'
4
+ const polyfills = `https://polyfill.io/v3/polyfill.min.js?features=${POLYFILLS.join(
5
+ '%2C',
6
+ )}&flags=gated`
4
7
 
5
8
  useServerHead({
6
9
  link: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-vio",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -41,16 +41,16 @@
41
41
  "prepare": "nuxt prepare .playground",
42
42
  "preview": "nuxt preview .playground",
43
43
  "start": "PORT=3001 node .playground/.output/server/index.mjs",
44
- "test:e2e": "playwright test",
45
- "test:e2e:dev": "cross-env NUXT_PUBLIC_IS_TESTING=1 WAIT_ON_TIMEOUT=100000 pnpm test:e2e",
46
- "test:e2e:prod": "cross-env NUXT_PUBLIC_IS_TESTING=1 WAIT_ON_TIMEOUT=10000 NODE_ENV=production pnpm test:e2e",
47
- "test:e2e:docker:build": "docker build -t test-e2e_base --build-arg UID=$(id -u) --build-arg GID=$(id -g) --target test-e2e_base ..",
48
- "test:e2e:docker:run": "docker run --rm -v \"$PWD/..:/srv/app\" -v \"$(pnpm store path):/srv/.pnpm-store\" test-e2e_base",
44
+ "test:e2e:dev": "cross-env NUXT_PUBLIC_IS_TESTING=1 pnpm test:e2e",
49
45
  "test:e2e:docker:br": "pnpm test:e2e:docker:build && pnpm test:e2e:docker:run",
50
- "test:e2e:docker:dev": "pnpm test:e2e:docker:br pnpm --dir src run test:e2e:dev",
46
+ "test:e2e:docker:build": "docker build -t test-e2e_base --build-arg UID=$(id -u) --build-arg GID=$(id -g) --target test-e2e_base ..",
51
47
  "test:e2e:docker:dev:update": "pnpm test:e2e:docker:dev --update-snapshots",
48
+ "test:e2e:docker:dev": "pnpm test:e2e:docker:br pnpm --dir src run test:e2e:dev",
49
+ "test:e2e:docker:prod:update": "pnpm test:e2e:docker:prod --update-snapshots",
52
50
  "test:e2e:docker:prod": "pnpm test:e2e:docker:br pnpm --dir src run test:e2e:prod",
53
- "test:e2e:docker:prod:update": "pnpm test:e2e:docker:prod --update-snapshots"
51
+ "test:e2e:docker:run": "docker run --rm -v \"$PWD/..:/srv/app\" -v \"$(pnpm store path):/srv/.pnpm-store\" test-e2e_base",
52
+ "test:e2e:prod": "cross-env NUXT_PUBLIC_IS_TESTING=1 NODE_ENV=production pnpm test:e2e",
53
+ "test:e2e": "playwright test"
54
54
  },
55
55
  "dependencies": {
56
56
  "@axe-core/playwright": "4.7.3",
@@ -61,7 +61,7 @@
61
61
  "@nuxtjs/html-validator": "1.5.2",
62
62
  "@nuxtjs/i18n": "8.0.0-rc.4",
63
63
  "@nuxtjs/tailwindcss": "6.8.0",
64
- "@nuxtseo/module": "2.0.0-beta.25",
64
+ "@nuxtseo/module": "2.0.0-beta.26",
65
65
  "@pinia/nuxt": "0.4.11",
66
66
  "@playwright/test": "1.37.1",
67
67
  "@tailwindcss/forms": "0.5.6",
@@ -78,12 +78,13 @@
78
78
  "cookie": "0.5.0",
79
79
  "dayjs": "2.0.0-alpha.4",
80
80
  "is-https": "4.0.0",
81
+ "jiti": "1.19.3",
81
82
  "jose": "4.14.6",
82
83
  "lodash-es": "4.17.21",
83
84
  "pinia": "2.1.6",
84
85
  "sweetalert2": "11.7.27",
85
86
  "vue-gtag": "2.0.1",
86
- "vue-tsc": "1.8.8"
87
+ "vue-tsc": "1.8.10"
87
88
  },
88
89
  "devDependencies": {
89
90
  "@intlify/eslint-plugin-vue-i18n": "3.0.0-next.3",
package/utils/auth.ts CHANGED
@@ -69,9 +69,8 @@ export const jwtStore = async ({
69
69
  }
70
70
 
71
71
  export const useJwtStore = () => {
72
- const { $urqlReset } = useNuxtApp()
72
+ const { $urqlReset, ssrContext } = useNuxtApp()
73
73
  const store = useVioAuthStore()
74
- const event = useRequestEvent()
75
74
 
76
75
  if (typeof $urqlReset !== 'function')
77
76
  throw new Error('`$urqlReset` is not a function!')
@@ -81,7 +80,7 @@ export const useJwtStore = () => {
81
80
  await jwtStore({
82
81
  $urqlReset,
83
82
  store,
84
- res: process.server ? event.node.res : undefined,
83
+ res: ssrContext ? ssrContext.event.node.res : undefined,
85
84
  jwt,
86
85
  })
87
86
  },
@@ -99,9 +98,8 @@ export const signOut = async ({
99
98
  }) => await jwtStore({ $urqlReset, store, res })
100
99
 
101
100
  export const useSignOut = () => {
102
- const { $urqlReset } = useNuxtApp()
101
+ const { $urqlReset, ssrContext } = useNuxtApp()
103
102
  const store = useVioAuthStore()
104
- const event = useRequestEvent()
105
103
 
106
104
  if (typeof $urqlReset !== 'function')
107
105
  throw new Error('`$urqlReset` is not a function!')
@@ -111,7 +109,7 @@ export const useSignOut = () => {
111
109
  await signOut({
112
110
  $urqlReset,
113
111
  store,
114
- res: process.server ? event.node.res : undefined,
112
+ res: ssrContext ? ssrContext.event.node.res : undefined,
115
113
  })
116
114
  },
117
115
  }
@@ -40,6 +40,7 @@ export const I18N_VUE_CONFIG = {
40
40
  }
41
41
  export const JWT_NAME = () =>
42
42
  `${process.env.NODE_ENV === 'production' ? '__Secure-' : ''}jwt`
43
+ export const POLYFILLS = ['Promise']
43
44
  export const REGEX_UUID =
44
45
  /^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/
45
46
  export const TIMEZONE_COOKIE_NAME = [COOKIE_PREFIX, 'tz'].join(COOKIE_SEPARATOR)
@@ -1,5 +1,3 @@
1
- import { IncomingMessage } from 'node:http'
2
-
3
1
  import { CombinedError } from '@urql/core'
4
2
  import { H3Event, getCookie } from 'h3'
5
3
 
@@ -79,10 +77,12 @@ export const getDomainTldPort = (host: string) => {
79
77
  return `${hostParts[hostParts.length - 2]}.${hostParts[hostParts.length - 1]}`
80
78
  }
81
79
 
82
- export const getHost = (req: IncomingMessage) => {
83
- if (!req.headers.host) throw new Error('Host header is not given!')
80
+ export const getHost = (event: H3Event) => {
81
+ const host = event.node.req.headers.host
82
+
83
+ if (!host) throw new Error('Host header is not given!')
84
84
 
85
- return req.headers.host
85
+ return host
86
86
  }
87
87
 
88
88
  export const getServiceHref = ({