@lobehub/lobehub 2.0.0-next.185 → 2.0.0-next.186
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/CHANGELOG.md +25 -0
- package/changelog/v1.json +9 -0
- package/e2e/src/support/webServer.ts +0 -1
- package/next.config.ts +14 -1
- package/package.json +2 -1
- package/packages/types/src/message/common/base.ts +1 -1
- package/packages/types/src/message/ui/chat.ts +3 -3
- package/packages/types/src/message/ui/extra.ts +2 -2
- package/packages/types/src/openai/plugin.ts +1 -1
- package/packages/types/src/session/agentSession.ts +1 -1
- package/packages/types/src/user/settings/index.ts +1 -1
- package/src/app/(backend)/oidc/[...oidc]/route.ts +2 -2
- package/src/app/[variants]/(auth)/oauth/consent/[uid]/page.tsx +2 -2
- package/src/envs/auth.ts +2 -0
- package/src/libs/next/config/define-config.ts +19 -10
- package/src/libs/next/proxy/define-config.ts +4 -5
- package/src/libs/trpc/lambda/context.ts +9 -11
- package/src/server/services/oidc/oidcProvider.ts +2 -2
- package/vercel.json +1 -1
- package/src/envs/oidc.ts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 2.0.0-next.186](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.185...v2.0.0-next.186)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2026-01-01**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Refactor oidc env to auth env.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Refactor oidc env to auth env, closes [#11095](https://github.com/lobehub/lobe-chat/issues/11095) ([6e8d4ff](https://github.com/lobehub/lobe-chat/commit/6e8d4ff))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
## [Version 2.0.0-next.185](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.184...v2.0.0-next.185)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2026-01-01**</sup>
|
package/changelog/v1.json
CHANGED
|
@@ -101,7 +101,6 @@ export async function startWebServer(options: WebServerOptions): Promise<void> {
|
|
|
101
101
|
...process.env,
|
|
102
102
|
// E2E test secret keys
|
|
103
103
|
BETTER_AUTH_SECRET: 'e2e-test-secret-key-for-better-auth-32chars!',
|
|
104
|
-
ENABLE_OIDC: '0',
|
|
105
104
|
KEY_VAULTS_SECRET: 'LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=',
|
|
106
105
|
// Disable email verification for e2e
|
|
107
106
|
NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION: '0',
|
package/next.config.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { defineConfig } from './src/libs/next/config/define-config';
|
|
2
2
|
|
|
3
|
-
const nextConfig = defineConfig({
|
|
3
|
+
const nextConfig = defineConfig({
|
|
4
|
+
experimental: {
|
|
5
|
+
webpackBuildWorker: true,
|
|
6
|
+
webpackMemoryOptimizations: true,
|
|
7
|
+
},
|
|
8
|
+
webpack: (webpackConfig, context) => {
|
|
9
|
+
const { dev } = context;
|
|
10
|
+
if (!dev) {
|
|
11
|
+
webpackConfig.cache = false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return webpackConfig;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
4
17
|
|
|
5
18
|
export default nextConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/lobehub",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.186",
|
|
4
4
|
"description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"build:analyze": "NODE_OPTIONS=--max-old-space-size=8192 ANALYZE=true next build --webpack",
|
|
41
41
|
"build:docker": "npm run prebuild && NODE_OPTIONS=--max-old-space-size=8192 DOCKER=true next build --webpack && npm run build-sitemap",
|
|
42
42
|
"build:electron": "cross-env NODE_OPTIONS=--max-old-space-size=8192 NEXT_PUBLIC_IS_DESKTOP_APP=1 tsx scripts/electronWorkflow/buildNextApp.mts",
|
|
43
|
+
"build:vercel": "npm run prebuild && cross-env NODE_OPTIONS=--max-old-space-size=6144 next build --webpack",
|
|
43
44
|
"clean:node_modules": "bash -lc 'set -e; echo \"Removing all node_modules...\"; rm -rf node_modules; pnpm -r exec rm -rf node_modules; rm -rf apps/desktop/node_modules; echo \"All node_modules removed.\"'",
|
|
44
45
|
"db:generate": "drizzle-kit generate && npm run db:generate-client && npm run workflow:dbml",
|
|
45
46
|
"db:generate-client": "tsx ./scripts/migrateClientDB/compile-migrations.ts",
|
|
@@ -107,7 +107,7 @@ export interface UIChatMessage {
|
|
|
107
107
|
content: string;
|
|
108
108
|
createdAt: number;
|
|
109
109
|
error?: ChatMessageError | null;
|
|
110
|
-
//
|
|
110
|
+
// Extended fields
|
|
111
111
|
extra?: ChatMessageExtra;
|
|
112
112
|
fileList?: ChatFileItem[];
|
|
113
113
|
/**
|
|
@@ -186,11 +186,11 @@ export interface UIChatMessage {
|
|
|
186
186
|
tool_call_id?: string;
|
|
187
187
|
tools?: ChatToolPayload[];
|
|
188
188
|
/**
|
|
189
|
-
*
|
|
189
|
+
* Messages saved to topic
|
|
190
190
|
*/
|
|
191
191
|
topicId?: string;
|
|
192
192
|
/**
|
|
193
|
-
*
|
|
193
|
+
* Observation trace ID
|
|
194
194
|
*/
|
|
195
195
|
traceId?: string;
|
|
196
196
|
updatedAt: number;
|
|
@@ -2,7 +2,7 @@ import debug from 'debug';
|
|
|
2
2
|
import { type NextRequest, NextResponse } from 'next/server';
|
|
3
3
|
import { URL } from 'node:url';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { authEnv } from '@/envs/auth';
|
|
6
6
|
import { createNodeRequest, createNodeResponse } from '@/libs/oidc-provider/http-adapter';
|
|
7
7
|
import { getOIDCProvider } from '@/server/services/oidc/oidcProvider';
|
|
8
8
|
|
|
@@ -17,7 +17,7 @@ const handler = async (req: NextRequest) => {
|
|
|
17
17
|
let responseCollector;
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
if (!
|
|
20
|
+
if (!authEnv.ENABLE_OIDC) {
|
|
21
21
|
log('OIDC is not enabled');
|
|
22
22
|
return new NextResponse('OIDC is not enabled', { status: 404 });
|
|
23
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { notFound } from 'next/navigation';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { authEnv } from '@/envs/auth';
|
|
4
4
|
import { defaultClients } from '@/libs/oidc-provider/config';
|
|
5
5
|
import { OIDCService } from '@/server/services/oidc';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ import Consent from './Consent';
|
|
|
9
9
|
import Login from './Login';
|
|
10
10
|
|
|
11
11
|
const InteractionPage = async (props: { params: Promise<{ uid: string }> }) => {
|
|
12
|
-
if (!
|
|
12
|
+
if (!authEnv.ENABLE_OIDC) return notFound();
|
|
13
13
|
|
|
14
14
|
const params = await props.params;
|
|
15
15
|
const uid = params.uid;
|
package/src/envs/auth.ts
CHANGED
|
@@ -284,6 +284,7 @@ export const getAuthConfig = () => {
|
|
|
284
284
|
|
|
285
285
|
// Generic JWKS key for signing/verifying JWTs
|
|
286
286
|
JWKS_KEY: z.string().optional(),
|
|
287
|
+
ENABLE_OIDC: z.boolean(),
|
|
287
288
|
},
|
|
288
289
|
|
|
289
290
|
runtimeEnv: {
|
|
@@ -407,6 +408,7 @@ export const getAuthConfig = () => {
|
|
|
407
408
|
|
|
408
409
|
// Generic JWKS key (fallback to OIDC_JWKS_KEY for backward compatibility)
|
|
409
410
|
JWKS_KEY: process.env.JWKS_KEY || process.env.OIDC_JWKS_KEY,
|
|
411
|
+
ENABLE_OIDC: !!(process.env.JWKS_KEY || process.env.OIDC_JWKS_KEY),
|
|
410
412
|
},
|
|
411
413
|
});
|
|
412
414
|
};
|
|
@@ -6,9 +6,11 @@ import type { Header, Redirect } from 'next/dist/lib/load-custom-routes';
|
|
|
6
6
|
import ReactComponentName from 'react-scan/react-component-name/webpack';
|
|
7
7
|
|
|
8
8
|
interface CustomNextConfig {
|
|
9
|
+
experimental?: NextConfig['experimental'];
|
|
9
10
|
headers?: Header[];
|
|
10
11
|
redirects?: Redirect[];
|
|
11
12
|
turbopack?: NextConfig['turbopack'];
|
|
13
|
+
webpack?: NextConfig['webpack'];
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export function defineConfig(config: CustomNextConfig) {
|
|
@@ -56,6 +58,7 @@ export function defineConfig(config: CustomNextConfig) {
|
|
|
56
58
|
webVitalsAttribution: ['CLS', 'LCP'],
|
|
57
59
|
webpackBuildWorker: true,
|
|
58
60
|
webpackMemoryOptimizations: true,
|
|
61
|
+
...config.experimental,
|
|
59
62
|
},
|
|
60
63
|
async headers() {
|
|
61
64
|
const securityHeaders = [
|
|
@@ -325,20 +328,20 @@ export function defineConfig(config: CustomNextConfig) {
|
|
|
325
328
|
ignoreBuildErrors: true,
|
|
326
329
|
},
|
|
327
330
|
|
|
328
|
-
webpack(
|
|
329
|
-
|
|
331
|
+
webpack(baseWebpackConfig, options) {
|
|
332
|
+
baseWebpackConfig.experiments = {
|
|
330
333
|
asyncWebAssembly: true,
|
|
331
334
|
layers: true,
|
|
332
335
|
};
|
|
333
336
|
|
|
334
337
|
// 开启该插件会导致 pglite 的 fs bundler 被改表
|
|
335
338
|
if (enableReactScan) {
|
|
336
|
-
|
|
339
|
+
baseWebpackConfig.plugins.push(ReactComponentName({}));
|
|
337
340
|
}
|
|
338
341
|
|
|
339
342
|
// to fix shikiji compile error
|
|
340
343
|
// refs: https://github.com/antfu/shikiji/issues/23
|
|
341
|
-
|
|
344
|
+
baseWebpackConfig.module.rules.push({
|
|
342
345
|
resolve: {
|
|
343
346
|
fullySpecified: false,
|
|
344
347
|
},
|
|
@@ -347,14 +350,14 @@ export function defineConfig(config: CustomNextConfig) {
|
|
|
347
350
|
});
|
|
348
351
|
|
|
349
352
|
// https://github.com/pinojs/pino/issues/688#issuecomment-637763276
|
|
350
|
-
|
|
353
|
+
baseWebpackConfig.externals.push('pino-pretty');
|
|
351
354
|
|
|
352
|
-
|
|
355
|
+
baseWebpackConfig.resolve.alias.canvas = false;
|
|
353
356
|
|
|
354
357
|
// to ignore epub2 compile error
|
|
355
358
|
// refs: https://github.com/lobehub/lobe-chat/discussions/6769
|
|
356
|
-
|
|
357
|
-
...
|
|
359
|
+
baseWebpackConfig.resolve.fallback = {
|
|
360
|
+
...baseWebpackConfig.resolve.fallback,
|
|
358
361
|
zipfile: false,
|
|
359
362
|
};
|
|
360
363
|
|
|
@@ -364,7 +367,7 @@ export function defineConfig(config: CustomNextConfig) {
|
|
|
364
367
|
) {
|
|
365
368
|
// fix the Worker URL cross-origin issue
|
|
366
369
|
// refs: https://github.com/lobehub/lobe-chat/pull/9624
|
|
367
|
-
|
|
370
|
+
baseWebpackConfig.module.rules.push({
|
|
368
371
|
generator: {
|
|
369
372
|
// @see https://webpack.js.org/configuration/module/#rulegeneratorpublicpath
|
|
370
373
|
publicPath: '/_next/',
|
|
@@ -375,7 +378,13 @@ export function defineConfig(config: CustomNextConfig) {
|
|
|
375
378
|
});
|
|
376
379
|
}
|
|
377
380
|
|
|
378
|
-
|
|
381
|
+
const updatedConfig = baseWebpackConfig;
|
|
382
|
+
|
|
383
|
+
if (config.webpack) {
|
|
384
|
+
return config.webpack(updatedConfig, options);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return updatedConfig;
|
|
379
388
|
},
|
|
380
389
|
};
|
|
381
390
|
|
|
@@ -12,7 +12,6 @@ import { LOBE_THEME_APPEARANCE } from '@/const/theme';
|
|
|
12
12
|
import { isDesktop } from '@/const/version';
|
|
13
13
|
import { appEnv } from '@/envs/app';
|
|
14
14
|
import { authEnv } from '@/envs/auth';
|
|
15
|
-
import { oidcEnv } from '@/envs/oidc';
|
|
16
15
|
import NextAuth from '@/libs/next-auth';
|
|
17
16
|
import { type Locales } from '@/locales/resources';
|
|
18
17
|
import { parseBrowserLanguage } from '@/utils/locale';
|
|
@@ -236,7 +235,7 @@ export function defineConfig() {
|
|
|
236
235
|
response.headers.set(OAUTH_AUTHORIZED, 'true');
|
|
237
236
|
|
|
238
237
|
// If OIDC is enabled and user is logged in, add OIDC session pre-sync header
|
|
239
|
-
if (
|
|
238
|
+
if (authEnv.ENABLE_OIDC && session?.user?.id) {
|
|
240
239
|
logNextAuth('OIDC session pre-sync: Setting %s = %s', OIDC_SESSION_HEADER, session.user.id);
|
|
241
240
|
response.headers.set(OIDC_SESSION_HEADER, session.user.id);
|
|
242
241
|
}
|
|
@@ -285,10 +284,10 @@ export function defineConfig() {
|
|
|
285
284
|
});
|
|
286
285
|
|
|
287
286
|
// If OIDC is enabled and Clerk user is logged in, add OIDC session pre-sync header
|
|
288
|
-
if (
|
|
287
|
+
if (authEnv.ENABLE_OIDC && data.userId) {
|
|
289
288
|
logClerk('OIDC session pre-sync: Setting %s = %s', OIDC_SESSION_HEADER, data.userId);
|
|
290
289
|
response.headers.set(OIDC_SESSION_HEADER, data.userId);
|
|
291
|
-
} else if (
|
|
290
|
+
} else if (authEnv.ENABLE_OIDC) {
|
|
292
291
|
logClerk('No Clerk user detected, not setting OIDC session sync header');
|
|
293
292
|
}
|
|
294
293
|
|
|
@@ -351,7 +350,7 @@ export function defineConfig() {
|
|
|
351
350
|
enableBetterAuth: authEnv.NEXT_PUBLIC_ENABLE_BETTER_AUTH,
|
|
352
351
|
enableClerk: authEnv.NEXT_PUBLIC_ENABLE_CLERK_AUTH,
|
|
353
352
|
enableNextAuth: authEnv.NEXT_PUBLIC_ENABLE_NEXT_AUTH,
|
|
354
|
-
enableOIDC:
|
|
353
|
+
enableOIDC: authEnv.ENABLE_OIDC,
|
|
355
354
|
});
|
|
356
355
|
|
|
357
356
|
return {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { type ClientSecretPayload } from '@lobechat/types';
|
|
2
|
-
import { parse } from 'cookie';
|
|
3
|
-
import debug from 'debug';
|
|
4
|
-
import { type User } from 'next-auth';
|
|
5
|
-
import { type NextRequest } from 'next/server';
|
|
6
|
-
|
|
7
1
|
import {
|
|
8
2
|
LOBE_CHAT_AUTH_HEADER,
|
|
9
3
|
LOBE_CHAT_OIDC_AUTH_HEADER,
|
|
10
4
|
enableBetterAuth,
|
|
11
5
|
enableClerk,
|
|
12
6
|
enableNextAuth,
|
|
13
|
-
} from '
|
|
14
|
-
import {
|
|
7
|
+
} from '@lobechat/const';
|
|
8
|
+
import { type ClientSecretPayload } from '@lobechat/types';
|
|
9
|
+
import { parse } from 'cookie';
|
|
10
|
+
import debug from 'debug';
|
|
11
|
+
import { type User } from 'next-auth';
|
|
12
|
+
import { type NextRequest } from 'next/server';
|
|
13
|
+
|
|
14
|
+
import { authEnv } from '@/envs/auth';
|
|
15
15
|
import { ClerkAuth, type IClerkAuth } from '@/libs/clerk-auth';
|
|
16
16
|
import { validateOIDCJWT } from '@/libs/oidc-provider/jwt';
|
|
17
17
|
|
|
@@ -129,11 +129,9 @@ export const createLambdaContext = async (request: NextRequest): Promise<LambdaC
|
|
|
129
129
|
let oidcAuth = null;
|
|
130
130
|
|
|
131
131
|
// Prioritize checking for OIDC authentication (both standard Authorization and custom Oidc-Auth headers)
|
|
132
|
-
if (
|
|
132
|
+
if (authEnv.ENABLE_OIDC) {
|
|
133
133
|
log('OIDC enabled, attempting OIDC authentication');
|
|
134
|
-
const standardAuthorization = request.headers.get('Authorization');
|
|
135
134
|
const oidcAuthToken = request.headers.get(LOBE_CHAT_OIDC_AUTH_HEADER);
|
|
136
|
-
log('Standard Authorization header: %s', standardAuthorization ? 'exists' : 'not found');
|
|
137
135
|
log('Oidc-Auth header: %s', oidcAuthToken ? 'exists' : 'not found');
|
|
138
136
|
|
|
139
137
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDBInstance } from '@/database/core/web-server';
|
|
2
|
-
import {
|
|
2
|
+
import { authEnv } from '@/envs/auth';
|
|
3
3
|
import { type OIDCProvider, createOIDCProvider } from '@/libs/oidc-provider/provider';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -13,7 +13,7 @@ let provider: OIDCProvider;
|
|
|
13
13
|
*/
|
|
14
14
|
export const getOIDCProvider = async (): Promise<OIDCProvider> => {
|
|
15
15
|
if (!provider) {
|
|
16
|
-
if (!
|
|
16
|
+
if (!authEnv.ENABLE_OIDC) {
|
|
17
17
|
throw new Error('OIDC is not enabled. Set ENABLE_OIDC=1 to enable it.');
|
|
18
18
|
}
|
|
19
19
|
|
package/vercel.json
CHANGED
package/src/envs/oidc.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createEnv } from '@t3-oss/env-nextjs';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
export const oidcEnv = createEnv({
|
|
5
|
-
client: {},
|
|
6
|
-
runtimeEnv: {
|
|
7
|
-
ENABLE_OIDC: process.env.ENABLE_OIDC === '1',
|
|
8
|
-
OIDC_JWKS_KEY: process.env.OIDC_JWKS_KEY,
|
|
9
|
-
},
|
|
10
|
-
server: {
|
|
11
|
-
// 是否启用 OIDC
|
|
12
|
-
ENABLE_OIDC: z.boolean().optional().default(false),
|
|
13
|
-
// OIDC 签名密钥
|
|
14
|
-
// 必须是一个包含私钥的 JWKS (JSON Web Key Set) 格式的 JSON 字符串。
|
|
15
|
-
// 可以使用 `node scripts/generate-oidc-jwk.mjs` 命令生成。
|
|
16
|
-
OIDC_JWKS_KEY: z.string().optional(),
|
|
17
|
-
},
|
|
18
|
-
});
|