@nitra/vite-boot 5.0.6 → 5.0.8

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/src/user.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/vite-boot",
3
- "version": "5.0.6",
3
+ "version": "5.0.8",
4
4
  "description": "Vite boot",
5
5
  "type": "module",
6
6
  "exports": {
package/src/user.js CHANGED
@@ -45,14 +45,25 @@ function intersection(a, b) {
45
45
  /**
46
46
  * Переводимо в анонімного користувача
47
47
  */
48
- export function cleanToken() {
48
+ export async function cleanToken() {
49
+ console.log('Cleaning token and user data')
49
50
  unsetUser()
50
51
 
51
52
  // видаляємо з localStorage
52
53
  localStorage.removeItem('__session')
53
54
 
54
55
  if (globalThis.cookieStore && typeof globalThis.cookieStore.delete === 'function') {
55
- globalThis.cookieStore.delete('__session', { path: '/', domain: import.meta.env.VITE_DOMAIN })
56
+ let safeDomain = import.meta.env.VITE_DOMAIN
57
+
58
+ if (typeof safeDomain === 'string' && safeDomain.startsWith('.')) {
59
+ safeDomain = safeDomain.slice(1)
60
+ }
61
+
62
+ await globalThis.cookieStore.delete({
63
+ name: '__session',
64
+ path: '/',
65
+ domain: safeDomain
66
+ })
56
67
  } else {
57
68
  // @ts-ignore
58
69
  // eslint-disable-next-line unicorn/no-document-cookie