@innertia-solutions/innertia-nuxt 0.1.86 → 0.1.88
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.
|
@@ -386,7 +386,8 @@ const loadDocx = async () => {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
|
|
389
|
+
// También al subir una versión nueva: el id no cambia, pero el contenido sí.
|
|
390
|
+
watch(() => [props.file?.id, props.file?.version], () => {
|
|
390
391
|
textContent.value = null
|
|
391
392
|
xlsxWorkbook.value = null
|
|
392
393
|
xlsxActiveIdx.value = 0
|
package/components/Modal.vue
CHANGED
|
@@ -4,7 +4,7 @@ import { IconX } from '@tabler/icons-vue'
|
|
|
4
4
|
/**
|
|
5
5
|
* <Modal> — Core modal. Sigue tokens semánticos (rounded-modal, bg-card,
|
|
6
6
|
* border-card-line). Variantes: center (default), drawer-right, drawer-left,
|
|
7
|
-
* fullscreen. Tamaños xs..
|
|
7
|
+
* fullscreen. Tamaños xs..7xl.
|
|
8
8
|
*
|
|
9
9
|
* No tiene lógica de negocio. Para casos típicos preferir:
|
|
10
10
|
* - <ModalConfirm> → confirmaciones con severities
|
|
@@ -14,7 +14,7 @@ import { IconX } from '@tabler/icons-vue'
|
|
|
14
14
|
const props = defineProps({
|
|
15
15
|
modelValue: { type: Boolean, default: false },
|
|
16
16
|
title: { type: String, default: '' },
|
|
17
|
-
size: { type: String, default: 'md', validator: v => ['xs','sm','md','lg','xl','2xl','3xl','fullscreen'].includes(v) },
|
|
17
|
+
size: { type: String, default: 'md', validator: v => ['xs','sm','md','lg','xl','2xl','3xl','4xl','5xl','6xl','7xl','fullscreen'].includes(v) },
|
|
18
18
|
variant: { type: String, default: 'center', validator: v => ['center','drawer-right','drawer-left','fullscreen'].includes(v) },
|
|
19
19
|
closable: { type: Boolean, default: true },
|
|
20
20
|
backdropDismiss: { type: Boolean, default: true },
|
|
@@ -38,6 +38,8 @@ const sizeClass = computed(() => {
|
|
|
38
38
|
return ({
|
|
39
39
|
xs: 'max-w-xs', sm: 'max-w-sm', md: 'max-w-md',
|
|
40
40
|
lg: 'max-w-lg', xl: 'max-w-xl', '2xl': 'max-w-2xl', '3xl': 'max-w-3xl',
|
|
41
|
+
// Wide modals (tables, side-by-side panels) that still read as a modal, not a full screen.
|
|
42
|
+
'4xl': 'max-w-4xl', '5xl': 'max-w-5xl', '6xl': 'max-w-6xl', '7xl': 'max-w-7xl',
|
|
41
43
|
}[props.size] ?? 'max-w-md')
|
|
42
44
|
})
|
|
43
45
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest'
|
|
2
|
-
import { decodeJwtPayload, shouldRefreshToken, createTokenRotator } from '../tokenRefresh'
|
|
2
|
+
import { decodeJwtPayload, isPlatformToken, shouldRefreshToken, createTokenRotator } from '../tokenRefresh'
|
|
3
3
|
|
|
4
4
|
function jwt(payload: Record<string, unknown>): string {
|
|
5
5
|
const b64 = (o: unknown) => Buffer.from(JSON.stringify(o)).toString('base64url')
|
|
@@ -30,8 +30,10 @@ describe('shouldRefreshToken', () => {
|
|
|
30
30
|
it('no renueva un token ya vencido (Laravel no lo acepta)', () => {
|
|
31
31
|
expect(shouldRefreshToken(ttl60(), iat + 3601)).toBe(false)
|
|
32
32
|
})
|
|
33
|
-
it('
|
|
34
|
-
expect(shouldRefreshToken(ttl60({ platform: true }), iat + 3500)).toBe(
|
|
33
|
+
it('renueva también tokens de plataforma (contra su propio endpoint)', () => {
|
|
34
|
+
expect(shouldRefreshToken(ttl60({ platform: true }), iat + 3500)).toBe(true)
|
|
35
|
+
expect(isPlatformToken(ttl60({ platform: true }))).toBe(true)
|
|
36
|
+
expect(isPlatformToken(ttl60())).toBe(false)
|
|
35
37
|
})
|
|
36
38
|
it('con TTL corto usa 1/3 de la vida como ventana (no renueva en cada request)', () => {
|
|
37
39
|
const short = jwt({ iat, exp: iat + 300 }) // 5 min
|
|
@@ -3,7 +3,7 @@ import type { H3Event } from 'h3'
|
|
|
3
3
|
import { readSession, writeSession } from './session'
|
|
4
4
|
import type { SessionData } from './session'
|
|
5
5
|
import { buildAuthHeaders, forwardClientHeaders } from './bff'
|
|
6
|
-
import { createTokenRotator, shouldRefreshToken } from './tokenRefresh'
|
|
6
|
+
import { createTokenRotator, isPlatformToken, shouldRefreshToken } from './tokenRefresh'
|
|
7
7
|
|
|
8
8
|
// Token de la sesión sellada con renovación deslizante (ver tokenRefresh.ts).
|
|
9
9
|
// Un rotador por proceso Nitro: deduplica refrescos concurrentes del mismo token.
|
|
@@ -15,7 +15,10 @@ function getRotator() {
|
|
|
15
15
|
refresh: async (token, ev) => {
|
|
16
16
|
if (!ev) return null
|
|
17
17
|
const config = useRuntimeConfig(ev)
|
|
18
|
-
|
|
18
|
+
// La consola de plataforma renueva contra su propio endpoint: un backend sin
|
|
19
|
+
// esa ruta responde 404 y se sigue con el token actual (no cambia de identidad).
|
|
20
|
+
const cfg = (config as any).authRefresh || {}
|
|
21
|
+
const path = String(isPlatformToken(token) ? (cfg.platformPath || 'platform/auth/refresh') : (cfg.path || 'auth/refresh')).replace(/^\/+/, '')
|
|
19
22
|
const res: any = await $fetch(`${String(config.apiInternalUrl).replace(/\/+$/, '')}/${path}`, {
|
|
20
23
|
method: 'POST',
|
|
21
24
|
// Un refresh colgado no debe bloquear el request del usuario: se sigue con el token actual.
|
|
@@ -32,20 +32,24 @@ export function decodeJwtPayload(token?: string | null): JwtPayload | null {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/** ¿El token es de la consola de plataforma (identidad separada)? */
|
|
36
|
+
export function isPlatformToken(token: string | null | undefined): boolean {
|
|
37
|
+
return Boolean(decodeJwtPayload(token)?.platform)
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
/** Ventana máxima (segundos) antes del vencimiento en que se renueva. */
|
|
36
41
|
export const REFRESH_WINDOW_SECONDS = 10 * 60
|
|
37
42
|
|
|
38
43
|
/**
|
|
39
44
|
* ¿Conviene renovar ahora? Sí cuando el token sigue vigente y le queda menos de
|
|
40
45
|
* min(10 min, 1/3 de su vida). El tope por vida evita renovar en cada request si
|
|
41
|
-
* el TTL configurado es corto. Los tokens de plataforma (claim `platform`)
|
|
42
|
-
* renuevan
|
|
43
|
-
*
|
|
46
|
+
* el TTL configurado es corto. Los tokens de plataforma (claim `platform`) también
|
|
47
|
+
* se renuevan, pero contra su propio endpoint (platform/auth/refresh, ver
|
|
48
|
+
* isPlatformToken): el auth/refresh normal de un backend antiguo no conserva el claim.
|
|
44
49
|
*/
|
|
45
50
|
export function shouldRefreshToken(token: string | null | undefined, nowSeconds: number, windowSeconds = REFRESH_WINDOW_SECONDS): boolean {
|
|
46
51
|
const payload = decodeJwtPayload(token)
|
|
47
52
|
if (!payload || typeof payload.exp !== 'number') return false
|
|
48
|
-
if (payload.platform) return false
|
|
49
53
|
const remaining = payload.exp - nowSeconds
|
|
50
54
|
if (remaining <= 0) return false
|
|
51
55
|
const issuedAt = typeof payload.iat === 'number' ? payload.iat : (typeof payload.nbf === 'number' ? payload.nbf : null)
|