@nitra/vite-boot 5.0.7 → 5.0.9

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