@innertia-solutions/innertia-nuxt 0.1.16 → 0.1.18

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.
@@ -14,7 +14,8 @@ export function useAuth() {
14
14
  */
15
15
  async function performLogin(context, email, password, remember = false) {
16
16
  authStore.rememberUser = remember
17
- const data = await api.post(`${context}/auth/login`, { email, password, context })
17
+ // Endpoint agnóstico de contexto: el contexto viaja en el payload (y luego en el JWT).
18
+ const data = await api.post('auth/login', { email, password, context })
18
19
  authStore.saveToken(data.token ?? data.access_token)
19
20
  authStore.setCurrentContext(context)
20
21
  queryClient.clear()
@@ -75,7 +76,9 @@ export function useAuth() {
75
76
  * Returns the URL string from the backend.
76
77
  */
77
78
  async function getOauthRedirectUrl(context, provider) {
78
- const data = await api.get(`${context}/auth/oauth/${provider}/redirect`)
79
+ // Endpoint agnóstico: el contexto viaja como query param (el backend lo
80
+ // codifica en el state de OAuth y lo recupera en el callback).
81
+ const data = await api.get(`auth/${provider}/redirect`, { params: { context } })
79
82
  return data.url
80
83
  }
81
84
 
@@ -83,7 +86,7 @@ export function useAuth() {
83
86
  * Handle OAuth callback. Same success path as performLogin.
84
87
  */
85
88
  async function handleOauthCallback(context, provider, code) {
86
- const data = await api.post(`${context}/auth/oauth/${provider}/callback`, { code })
89
+ const data = await api.post(`auth/${provider}/callback`, { code, context })
87
90
  authStore.saveToken(data.token ?? data.access_token)
88
91
  authStore.setCurrentContext(context)
89
92
  queryClient.clear()
@@ -0,0 +1,26 @@
1
+ /**
2
+ * useTheme — lee y cambia el tema dark/light.
3
+ *
4
+ * Usa la cookie `hs_theme` para compatibilidad SSR con el plugin appearance.ts
5
+ * y con el componente <AppSwitchColorTheme />.
6
+ */
7
+ export function useTheme() {
8
+ const cookie = useCookie<'dark' | 'light'>('hs_theme', {
9
+ default: () => 'light',
10
+ sameSite: 'lax',
11
+ maxAge: 60 * 60 * 24 * 365,
12
+ })
13
+
14
+ const isDark = computed(() => cookie.value === 'dark')
15
+
16
+ const toggle = () => {
17
+ const next = cookie.value === 'dark' ? 'light' : 'dark'
18
+ cookie.value = next
19
+ if (import.meta.client) {
20
+ document.documentElement.classList.toggle('dark', next === 'dark')
21
+ localStorage.setItem('hs_theme', next)
22
+ }
23
+ }
24
+
25
+ return { isDark, toggle }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/innertia-nuxt",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Innertia Solutions — Nuxt layer unificada: core, auth, multitenancy, theme y app contexts",
5
5
  "keywords": [
6
6
  "nuxt",