lf-pagebuilder-vue 0.0.16 → 0.0.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.
- package/README.md +22 -14
- package/dist/components/Pagebuilder.vue.d.ts +4 -8
- package/dist/index.cjs +1 -1
- package/dist/index.js +959 -994
- package/dist/limbo/index.d.ts +1 -1
- package/dist/limbo/tokenHandler.d.ts +28 -0
- package/dist/limbo.cjs +1 -1
- package/dist/limbo.js +46 -24
- package/package.json +1 -1
package/dist/limbo/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* import { createLimboTokenHandler } from 'lf-pagebuilder-vue/limbo';
|
|
8
8
|
*/
|
|
9
|
-
export { createLimboTokenHandler, LIMBO_API_URLS, LIMBO_ENV_VARS, type LimboTokenConfig, type LimboTokenResponse, } from './tokenHandler';
|
|
9
|
+
export { createLimboTokenHandler, fetchLimboToken, LIMBO_API_URLS, LIMBO_ENV_VARS, type LimboTokenConfig, type LimboTokenResponse, type FetchLimboTokenResult, } from './tokenHandler';
|
|
10
10
|
export { default } from './tokenHandler';
|
|
@@ -53,6 +53,34 @@ export interface LimboTokenResponse {
|
|
|
53
53
|
details?: string;
|
|
54
54
|
hint?: string;
|
|
55
55
|
}
|
|
56
|
+
export interface FetchLimboTokenResult {
|
|
57
|
+
token: string;
|
|
58
|
+
expires_in: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Obtiene un token JWT de Limbo directamente (server-side).
|
|
62
|
+
*
|
|
63
|
+
* Usar en el frontmatter de páginas Astro o en getServerSideProps de Next.js
|
|
64
|
+
* para obtener el token y pasarlo como prop al componente Pagebuilder.
|
|
65
|
+
*
|
|
66
|
+
* @example Astro
|
|
67
|
+
* ```astro
|
|
68
|
+
* ---
|
|
69
|
+
* import { fetchLimboToken } from 'lf-pagebuilder-vue/limbo';
|
|
70
|
+
*
|
|
71
|
+
* const { token } = await fetchLimboToken({
|
|
72
|
+
* publicKey: import.meta.env.PUBLIC_LIMBO_PUBLIC_KEY,
|
|
73
|
+
* isProduction: import.meta.env.IS_PROD === 'TRUE'
|
|
74
|
+
* });
|
|
75
|
+
* ---
|
|
76
|
+
* <Pagebuilder limboToken={token} client:only="vue" />
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function fetchLimboToken(config: {
|
|
80
|
+
publicKey: string;
|
|
81
|
+
isProduction?: boolean;
|
|
82
|
+
limboApiUrl?: string;
|
|
83
|
+
}): Promise<FetchLimboTokenResult>;
|
|
56
84
|
/**
|
|
57
85
|
* Crea un handler para obtener tokens JWT de Limbo.
|
|
58
86
|
*
|
package/dist/limbo.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a={production:"https://limbo.lefebvre.es",development:"https://led-dev-limbo-dev.eu.els.local"};async function y(u){const{publicKey:n,isProduction:c=!1,limboApiUrl:p}=u,d=p||(c?a.production:a.development);if(!n)throw new Error("[Limbo] publicKey es requerida para obtener token");const l=`${d}/auth/token`,r=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({public_key:n})});if(!r.ok){const e=await r.text();throw new Error(`[Limbo] Error obteniendo token: ${r.status} - ${e}`)}const s=await r.json();if(!s.token)throw new Error("[Limbo] La respuesta no contiene token");return{token:s.token,expires_in:s.expires_in||3600}}function b(u){const{publicKey:n,isProduction:c=!1,limboApiUrl:p,allowPublicKeyOverride:d=!0}=u,l=p||(c?a.production:a.development);return n||console.error("[Limbo Token Handler] PUBLIC_LIMBO_PUBLIC_KEY no está configurada"),console.log(`[Limbo Token Handler] Configurado para ${c?"PRODUCCIÓN":"DESARROLLO"}: ${l}`),async function({request:s}){try{let e=n;if(d)try{const i=await s.json();i.public_key&&(e=i.public_key)}catch{}if(!e)return new Response(JSON.stringify({success:!1,error:"PUBLIC_LIMBO_PUBLIC_KEY no configurada"}),{status:400,headers:{"Content-Type":"application/json"}});const o=`${l}/auth/token`;console.log("[Limbo Proxy] Requesting token from:",o),console.log("[Limbo Proxy] Using public_key:",e.substring(0,10)+"...");const t=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({public_key:e})});if(!t.ok){const i=await t.text();return console.error("[Limbo Proxy] Error response:",t.status,i),new Response(JSON.stringify({success:!1,error:`API error: ${t.status}`,details:i}),{status:t.status,headers:{"Content-Type":"application/json"}})}const f=await t.json();return console.log("[Limbo Proxy] Token obtained successfully"),new Response(JSON.stringify(f),{status:200,headers:{"Content-Type":"application/json"}})}catch(e){console.error("[Limbo Proxy] Error completo:",e);let o="Unknown error";return e instanceof Error&&(o=e.message,"cause"in e&&e.cause&&(o+=` (cause: ${JSON.stringify(e.cause)})`)),new Response(JSON.stringify({success:!1,error:o,hint:"Verifica que la API de Limbo sea accesible desde el servidor"}),{status:500,headers:{"Content-Type":"application/json"}})}}}const L={PUBLIC_KEY:"PUBLIC_LIMBO_PUBLIC_KEY",IS_PROD:"IS_PROD"};exports.LIMBO_API_URLS=a;exports.LIMBO_ENV_VARS=L;exports.createLimboTokenHandler=b;exports.default=b;exports.fetchLimboToken=y;
|
package/dist/limbo.js
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
const
|
|
1
|
+
const l = {
|
|
2
2
|
production: "https://limbo.lefebvre.es",
|
|
3
3
|
development: "https://led-dev-limbo-dev.eu.els.local"
|
|
4
4
|
};
|
|
5
|
-
function
|
|
5
|
+
async function f(u) {
|
|
6
|
+
const { publicKey: n, isProduction: a = !1, limboApiUrl: p } = u, d = p || (a ? l.production : l.development);
|
|
7
|
+
if (!n)
|
|
8
|
+
throw new Error("[Limbo] publicKey es requerida para obtener token");
|
|
9
|
+
const c = `${d}/auth/token`, r = await fetch(c, {
|
|
10
|
+
method: "POST",
|
|
11
|
+
headers: { "Content-Type": "application/json" },
|
|
12
|
+
body: JSON.stringify({ public_key: n })
|
|
13
|
+
});
|
|
14
|
+
if (!r.ok) {
|
|
15
|
+
const e = await r.text();
|
|
16
|
+
throw new Error(`[Limbo] Error obteniendo token: ${r.status} - ${e}`);
|
|
17
|
+
}
|
|
18
|
+
const s = await r.json();
|
|
19
|
+
if (!s.token)
|
|
20
|
+
throw new Error("[Limbo] La respuesta no contiene token");
|
|
21
|
+
return {
|
|
22
|
+
token: s.token,
|
|
23
|
+
expires_in: s.expires_in || 3600
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function y(u) {
|
|
6
27
|
const {
|
|
7
28
|
publicKey: n,
|
|
8
|
-
isProduction:
|
|
9
|
-
limboApiUrl:
|
|
10
|
-
allowPublicKeyOverride:
|
|
11
|
-
} =
|
|
12
|
-
return n || console.error("[Limbo Token Handler] PUBLIC_LIMBO_PUBLIC_KEY no está configurada"), console.log(`[Limbo Token Handler] Configurado para ${
|
|
29
|
+
isProduction: a = !1,
|
|
30
|
+
limboApiUrl: p,
|
|
31
|
+
allowPublicKeyOverride: d = !0
|
|
32
|
+
} = u, c = p || (a ? l.production : l.development);
|
|
33
|
+
return n || console.error("[Limbo Token Handler] PUBLIC_LIMBO_PUBLIC_KEY no está configurada"), console.log(`[Limbo Token Handler] Configurado para ${a ? "PRODUCCIÓN" : "DESARROLLO"}: ${c}`), async function({ request: s }) {
|
|
13
34
|
try {
|
|
14
35
|
let e = n;
|
|
15
|
-
if (
|
|
36
|
+
if (d)
|
|
16
37
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
38
|
+
const i = await s.json();
|
|
39
|
+
i.public_key && (e = i.public_key);
|
|
19
40
|
} catch {
|
|
20
41
|
}
|
|
21
42
|
if (!e)
|
|
@@ -29,9 +50,9 @@ function y(c) {
|
|
|
29
50
|
headers: { "Content-Type": "application/json" }
|
|
30
51
|
}
|
|
31
52
|
);
|
|
32
|
-
const o = `${
|
|
53
|
+
const o = `${c}/auth/token`;
|
|
33
54
|
console.log("[Limbo Proxy] Requesting token from:", o), console.log("[Limbo Proxy] Using public_key:", e.substring(0, 10) + "...");
|
|
34
|
-
const
|
|
55
|
+
const t = await fetch(o, {
|
|
35
56
|
method: "POST",
|
|
36
57
|
headers: {
|
|
37
58
|
"Content-Type": "application/json"
|
|
@@ -40,22 +61,22 @@ function y(c) {
|
|
|
40
61
|
public_key: e
|
|
41
62
|
})
|
|
42
63
|
});
|
|
43
|
-
if (!
|
|
44
|
-
const
|
|
45
|
-
return console.error("[Limbo Proxy] Error response:",
|
|
64
|
+
if (!t.ok) {
|
|
65
|
+
const i = await t.text();
|
|
66
|
+
return console.error("[Limbo Proxy] Error response:", t.status, i), new Response(
|
|
46
67
|
JSON.stringify({
|
|
47
68
|
success: !1,
|
|
48
|
-
error: `API error: ${
|
|
49
|
-
details:
|
|
69
|
+
error: `API error: ${t.status}`,
|
|
70
|
+
details: i
|
|
50
71
|
}),
|
|
51
72
|
{
|
|
52
|
-
status:
|
|
73
|
+
status: t.status,
|
|
53
74
|
headers: { "Content-Type": "application/json" }
|
|
54
75
|
}
|
|
55
76
|
);
|
|
56
77
|
}
|
|
57
|
-
const
|
|
58
|
-
return console.log("[Limbo Proxy] Token obtained successfully"), new Response(JSON.stringify(
|
|
78
|
+
const b = await t.json();
|
|
79
|
+
return console.log("[Limbo Proxy] Token obtained successfully"), new Response(JSON.stringify(b), {
|
|
59
80
|
status: 200,
|
|
60
81
|
headers: { "Content-Type": "application/json" }
|
|
61
82
|
});
|
|
@@ -76,15 +97,16 @@ function y(c) {
|
|
|
76
97
|
}
|
|
77
98
|
};
|
|
78
99
|
}
|
|
79
|
-
const
|
|
100
|
+
const L = {
|
|
80
101
|
/** Variable de entorno para la Public Key (con prefijo PUBLIC_ para cliente) */
|
|
81
102
|
PUBLIC_KEY: "PUBLIC_LIMBO_PUBLIC_KEY",
|
|
82
103
|
/** Variable de entorno para indicar si es producción */
|
|
83
104
|
IS_PROD: "IS_PROD"
|
|
84
105
|
};
|
|
85
106
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
l as LIMBO_API_URLS,
|
|
108
|
+
L as LIMBO_ENV_VARS,
|
|
88
109
|
y as createLimboTokenHandler,
|
|
89
|
-
y as default
|
|
110
|
+
y as default,
|
|
111
|
+
f as fetchLimboToken
|
|
90
112
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lf-pagebuilder-vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Constructor de páginas visual basado en Vue.js que permite crear y diseñar páginas web de forma intuitiva mediante componentes arrastrables y configurables",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|