@lastbrain/ai-ui-core 1.0.47 → 1.0.49
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/dist/client/createClient.d.ts +4 -0
- package/dist/client/createClient.d.ts.map +1 -1
- package/dist/client/createClient.js +62 -42
- package/dist/client/lb-client.d.ts +48 -59
- package/dist/client/lb-client.d.ts.map +1 -1
- package/dist/client/lb-client.js +140 -116
- package/dist/route-handlers/nextjs/enhanced-gateway.d.ts +17 -13
- package/dist/route-handlers/nextjs/enhanced-gateway.d.ts.map +1 -1
- package/dist/route-handlers/nextjs/enhanced-gateway.js +13 -158
- package/dist/route-handlers/nextjs/lb-proxy.d.ts.map +1 -1
- package/dist/route-handlers/nextjs/lb-proxy.js +16 -7
- package/dist/types/auth.d.ts +2 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/createClient.ts +73 -47
- package/src/client/lb-client.ts +205 -138
- package/src/route-handlers/nextjs/enhanced-gateway.ts +14 -233
- package/src/route-handlers/nextjs/lb-proxy.ts +16 -7
- package/src/types/auth.ts +2 -0
- package/src/types/index.ts +3 -1
|
@@ -77,10 +77,10 @@ export function createLBProxyHandler(config: LBProxyConfig = {}) {
|
|
|
77
77
|
|
|
78
78
|
// Routes publiques qui ne nécessitent pas d'authentification
|
|
79
79
|
const publicPaths = [
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"auth/session",
|
|
83
|
-
"
|
|
80
|
+
"public/login",
|
|
81
|
+
"public/status",
|
|
82
|
+
"auth/session/verify",
|
|
83
|
+
"auth/session/logout",
|
|
84
84
|
];
|
|
85
85
|
const isPublicPath = publicPaths.some((p) => path.startsWith(p));
|
|
86
86
|
|
|
@@ -105,21 +105,30 @@ export function createLBProxyHandler(config: LBProxyConfig = {}) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
const authorization = request.headers.get("authorization");
|
|
108
|
+
const explicitApiKeyHeader = request.headers.get("x-lb-api-key");
|
|
109
|
+
const sessionToken = request.cookies.get(sessionCookieName)?.value;
|
|
108
110
|
if (authorization) {
|
|
109
111
|
headers["Authorization"] = authorization;
|
|
110
112
|
}
|
|
113
|
+
if (explicitApiKeyHeader) {
|
|
114
|
+
headers["x-lb-api-key"] = explicitApiKeyHeader;
|
|
115
|
+
}
|
|
116
|
+
if (sessionToken) {
|
|
117
|
+
// Always forward lb_session cookie to allow backend fallback auth,
|
|
118
|
+
// even when an Authorization header is present.
|
|
119
|
+
headers["Cookie"] = `${sessionCookieName}=${sessionToken}`;
|
|
120
|
+
}
|
|
111
121
|
|
|
112
122
|
// Authentification : LB_API_KEY ou session cookie
|
|
113
|
-
if (!authorization) {
|
|
123
|
+
if (!authorization && !explicitApiKeyHeader) {
|
|
114
124
|
if (apiKey) {
|
|
125
|
+
headers["x-lb-api-key"] = apiKey;
|
|
115
126
|
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
116
127
|
} else {
|
|
117
128
|
// Lire le cookie de session
|
|
118
|
-
const sessionToken = request.cookies.get(sessionCookieName)?.value;
|
|
119
129
|
if (sessionToken) {
|
|
120
130
|
// Envoyer le cookie à la fois comme Authorization ET comme Cookie
|
|
121
131
|
headers["Authorization"] = `Bearer ${sessionToken}`;
|
|
122
|
-
headers["Cookie"] = `${sessionCookieName}=${sessionToken}`;
|
|
123
132
|
console.log("[LB Proxy] Forwarding session cookie:", {
|
|
124
133
|
name: sessionCookieName,
|
|
125
134
|
hasValue: !!sessionToken,
|
package/src/types/auth.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface LBAuthConfig {
|
|
|
11
11
|
baseUrl?: string;
|
|
12
12
|
/** Clé API LastBrain (côté serveur uniquement) */
|
|
13
13
|
apiKey?: string;
|
|
14
|
+
/** API key sélectionnée (utile en mode supabase) */
|
|
15
|
+
selectedApiKeyId?: string;
|
|
14
16
|
/** Mode d'authentification */
|
|
15
17
|
mode?: "env-key" | "session" | "auto";
|
|
16
18
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -124,7 +124,9 @@ export interface AiStatus {
|
|
|
124
124
|
|
|
125
125
|
export interface ClientConfig {
|
|
126
126
|
baseUrl: string;
|
|
127
|
-
apiKeyId
|
|
127
|
+
apiKeyId?: string;
|
|
128
|
+
sessionToken?: string;
|
|
129
|
+
credentials?: RequestCredentials;
|
|
128
130
|
timeout?: number;
|
|
129
131
|
retries?: number;
|
|
130
132
|
}
|