nuxt-auther 1.2.0 → 1.2.2

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.
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-auther",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "configKey": "auth",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.0.0 <5.0.0"
package/dist/module.mjs CHANGED
@@ -7,7 +7,7 @@ import { existsSync } from 'fs';
7
7
  import { hash } from 'ohash';
8
8
 
9
9
  const name = "nuxt-auther";
10
- const version = "1.2.0";
10
+ const version = "1.2.2";
11
11
 
12
12
  const OAUTH2DEFAULTS = {
13
13
  accessType: void 0,
@@ -246,7 +246,7 @@ import { serialize } from 'cookie-es'
246
246
 
247
247
  const options = ${serialize(opt, { space: 4 })}
248
248
 
249
- function addTokenPrefix(token: string | boolean, tokenType: string | false): string | boolean {
249
+ function addTokenPrefix(token, tokenType) {
250
250
  if (!token || !tokenType || typeof token !== 'string' || token.startsWith(tokenType)) {
251
251
  return token;
252
252
  }
@@ -320,6 +320,8 @@ export default defineEventHandler(async (event) => {
320
320
 
321
321
  let cookies = event.node.res.getHeader('Set-Cookie') as string[] || [];
322
322
 
323
+ cookies = Array.isArray(cookies) ? cookies : cookies ? [cookies] : [];
324
+
323
325
  const refreshCookieValue = response._data?.[options.strategy?.refreshToken?.property]
324
326
  if (config.stores.cookie.enabled && refreshCookieValue && options.strategy.refreshToken.httpOnly) {
325
327
  const refreshCookie = serialize(refreshCookieName, refreshCookieValue, { ...config.stores.cookie.options, httpOnly: true })
@@ -355,7 +357,7 @@ import { serialize } from 'cookie-es'
355
357
 
356
358
  const options = ${serialize(opt, { space: 4 })}
357
359
 
358
- function addTokenPrefix(token: string | boolean, tokenType: string | false): string | boolean {
360
+ function addTokenPrefix(token, tokenType) {
359
361
  if (!token || !tokenType || typeof token !== 'string' || token.startsWith(tokenType)) {
360
362
  return token;
361
363
  }
@@ -425,6 +427,8 @@ export default defineEventHandler(async (event) => {
425
427
 
426
428
  let cookies = event.node.res.getHeader('Set-Cookie') as string[] || [];
427
429
 
430
+ cookies = Array.isArray(cookies) ? cookies : cookies ? [cookies] : [];
431
+
428
432
  const refreshCookieValue = response._data?.[options.strategy?.refreshToken?.property]
429
433
  if (config.stores.cookie.enabled && refreshCookieValue && options.strategy.refreshToken.httpOnly) {
430
434
  const refreshCookie = serialize(refreshCookieName, refreshCookieValue, { ...config.stores.cookie.options, httpOnly: true })
@@ -106,7 +106,7 @@ import { serialize } from 'cookie-es'
106
106
 
107
107
  const options = ${serialize(opt, { space: 4 })}
108
108
 
109
- function addTokenPrefix(token: string | boolean, tokenType: string | false): string | boolean {
109
+ function addTokenPrefix(token, tokenType) {
110
110
  if (!token || !tokenType || typeof token !== 'string' || token.startsWith(tokenType)) {
111
111
  return token;
112
112
  }
@@ -180,6 +180,8 @@ export default defineEventHandler(async (event) => {
180
180
 
181
181
  let cookies = event.node.res.getHeader('Set-Cookie') as string[] || [];
182
182
 
183
+ cookies = Array.isArray(cookies) ? cookies : cookies ? [cookies] : [];
184
+
183
185
  const refreshCookieValue = response._data?.[options.strategy?.refreshToken?.property]
184
186
  if (config.stores.cookie.enabled && refreshCookieValue && options.strategy.refreshToken.httpOnly) {
185
187
  const refreshCookie = serialize(refreshCookieName, refreshCookieValue, { ...config.stores.cookie.options, httpOnly: true })
@@ -215,7 +217,7 @@ import { serialize } from 'cookie-es'
215
217
 
216
218
  const options = ${serialize(opt, { space: 4 })}
217
219
 
218
- function addTokenPrefix(token: string | boolean, tokenType: string | false): string | boolean {
220
+ function addTokenPrefix(token, tokenType) {
219
221
  if (!token || !tokenType || typeof token !== 'string' || token.startsWith(tokenType)) {
220
222
  return token;
221
223
  }
@@ -285,6 +287,8 @@ export default defineEventHandler(async (event) => {
285
287
 
286
288
  let cookies = event.node.res.getHeader('Set-Cookie') as string[] || [];
287
289
 
290
+ cookies = Array.isArray(cookies) ? cookies : cookies ? [cookies] : [];
291
+
288
292
  const refreshCookieValue = response._data?.[options.strategy?.refreshToken?.property]
289
293
  if (config.stores.cookie.enabled && refreshCookieValue && options.strategy.refreshToken.httpOnly) {
290
294
  const refreshCookie = serialize(refreshCookieName, refreshCookieValue, { ...config.stores.cookie.options, httpOnly: true })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-auther",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Authentication module for Nuxt.JS",
5
5
  "homepage": "https://github.com/zerosdev/nuxt-auther",
6
6
  "author": "zerosdev",
@@ -69,4 +69,4 @@
69
69
  "access": "public"
70
70
  },
71
71
  "packageManager": "yarn@4.9.2"
72
- }
72
+ }