@lobehub/chat 1.100.1 → 1.101.0
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 +58 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/changelog/v1.json +21 -0
- package/docs/development/basic/add-new-ai-image-model.mdx +36 -0
- package/docs/development/basic/add-new-ai-image-model.zh-CN.mdx +0 -0
- package/locales/ar/components.json +5 -4
- package/locales/ar/models.json +3 -0
- package/locales/bg-BG/components.json +5 -4
- package/locales/bg-BG/models.json +3 -0
- package/locales/de-DE/components.json +5 -4
- package/locales/de-DE/models.json +3 -0
- package/locales/en-US/components.json +5 -4
- package/locales/en-US/models.json +3 -0
- package/locales/es-ES/components.json +5 -4
- package/locales/es-ES/models.json +3 -0
- package/locales/fa-IR/components.json +5 -4
- package/locales/fa-IR/models.json +3 -0
- package/locales/fr-FR/components.json +5 -4
- package/locales/fr-FR/models.json +3 -0
- package/locales/it-IT/components.json +5 -4
- package/locales/it-IT/models.json +3 -0
- package/locales/ja-JP/components.json +5 -4
- package/locales/ja-JP/models.json +3 -0
- package/locales/ko-KR/components.json +5 -4
- package/locales/ko-KR/models.json +3 -0
- package/locales/nl-NL/components.json +5 -4
- package/locales/nl-NL/models.json +3 -0
- package/locales/pl-PL/components.json +5 -4
- package/locales/pl-PL/models.json +3 -0
- package/locales/pt-BR/components.json +5 -4
- package/locales/pt-BR/models.json +3 -0
- package/locales/ru-RU/components.json +5 -4
- package/locales/ru-RU/models.json +3 -0
- package/locales/tr-TR/components.json +5 -4
- package/locales/tr-TR/models.json +3 -0
- package/locales/vi-VN/components.json +5 -4
- package/locales/vi-VN/models.json +3 -0
- package/locales/zh-CN/components.json +5 -4
- package/locales/zh-CN/models.json +3 -0
- package/locales/zh-TW/components.json +5 -4
- package/locales/zh-TW/models.json +3 -0
- package/package.json +1 -1
- package/src/app/(backend)/middleware/auth/index.ts +28 -7
- package/src/app/[variants]/(main)/image/@menu/components/SeedNumberInput/index.tsx +24 -9
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/DimensionControlGroup.tsx +0 -1
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ImageUpload.tsx +161 -39
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/MultiImagesUpload/ImageManageModal.tsx +10 -10
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/MultiImagesUpload/index.tsx +153 -83
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/SeedNumberInput.tsx +2 -11
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/hooks/useDragAndDrop.ts +71 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/style.ts +17 -0
- package/src/config/aiModels/zhipu.ts +29 -6
- package/src/const/auth.ts +1 -0
- package/src/libs/model-runtime/utils/openaiCompatibleFactory/index.test.ts +20 -3
- package/src/libs/model-runtime/utils/openaiCompatibleFactory/index.ts +20 -11
- package/src/libs/oidc-provider/jwt.ts +22 -13
- package/src/libs/trpc/lambda/context.ts +8 -2
- package/src/locales/default/components.ts +4 -3
@@ -41,10 +41,7 @@ export const getJWKS = (): object => {
|
|
41
41
|
}
|
42
42
|
};
|
43
43
|
|
44
|
-
|
45
|
-
* 从环境变量中获取 JWKS 并提取第一个 RSA 密钥
|
46
|
-
*/
|
47
|
-
const getJWKSPublicKey = async () => {
|
44
|
+
const getVerificationKey = async () => {
|
48
45
|
try {
|
49
46
|
const jwksString = oidcEnv.OIDC_JWKS_KEY;
|
50
47
|
|
@@ -58,20 +55,32 @@ const getJWKSPublicKey = async () => {
|
|
58
55
|
throw new Error('JWKS 格式无效: 缺少或为空的 keys 数组');
|
59
56
|
}
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
if (!rsaKey) {
|
58
|
+
const privateRsaKey = jwks.keys.find((key: any) => key.alg === 'RS256' && key.kty === 'RSA');
|
59
|
+
if (!privateRsaKey) {
|
65
60
|
throw new Error('JWKS 中没有找到 RS256 算法的 RSA 密钥');
|
66
61
|
}
|
67
62
|
|
68
|
-
//
|
69
|
-
|
63
|
+
// 创建一个只包含公钥组件的“纯净”JWK对象。
|
64
|
+
// RSA公钥的关键字段是 kty, n, e。其他如 kid, alg, use 也是公共的。
|
65
|
+
const publicKeyJwk = {
|
66
|
+
alg: privateRsaKey.alg,
|
67
|
+
e: privateRsaKey.e,
|
68
|
+
kid: privateRsaKey.kid,
|
69
|
+
kty: privateRsaKey.kty,
|
70
|
+
n: privateRsaKey.n,
|
71
|
+
use: privateRsaKey.use,
|
72
|
+
};
|
73
|
+
|
74
|
+
// 移除任何可能存在的 undefined 字段,保持对象干净
|
75
|
+
Object.keys(publicKeyJwk).forEach(
|
76
|
+
(key) => (publicKeyJwk as any)[key] === undefined && delete (publicKeyJwk as any)[key],
|
77
|
+
);
|
70
78
|
|
71
|
-
|
79
|
+
// 现在,无论在哪个环境下,`importJWK` 都会将这个对象正确地识别为一个公钥。
|
80
|
+
return await importJWK(publicKeyJwk, 'RS256');
|
72
81
|
} catch (error) {
|
73
82
|
log('获取 JWKS 公钥失败: %O', error);
|
74
|
-
throw new Error(`JWKS
|
83
|
+
throw new Error(`JWKS 公key获取失败: ${(error as Error).message}`);
|
75
84
|
}
|
76
85
|
};
|
77
86
|
|
@@ -85,7 +94,7 @@ export const validateOIDCJWT = async (token: string) => {
|
|
85
94
|
log('开始验证 OIDC JWT token');
|
86
95
|
|
87
96
|
// 获取公钥
|
88
|
-
const publicKey = await
|
97
|
+
const publicKey = await getVerificationKey();
|
89
98
|
|
90
99
|
// 验证 JWT
|
91
100
|
const { payload } = await jwtVerify(token, publicKey, {
|
@@ -3,7 +3,13 @@ import debug from 'debug';
|
|
3
3
|
import { User } from 'next-auth';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
JWTPayload,
|
8
|
+
LOBE_CHAT_AUTH_HEADER,
|
9
|
+
LOBE_CHAT_OIDC_AUTH_HEADER,
|
10
|
+
enableClerk,
|
11
|
+
enableNextAuth,
|
12
|
+
} from '@/const/auth';
|
7
13
|
import { oidcEnv } from '@/envs/oidc';
|
8
14
|
import { ClerkAuth, IClerkAuth } from '@/libs/clerk-auth';
|
9
15
|
import { validateOIDCJWT } from '@/libs/oidc-provider/jwt';
|
@@ -102,7 +108,7 @@ export const createLambdaContext = async (request: NextRequest): Promise<LambdaC
|
|
102
108
|
if (oidcEnv.ENABLE_OIDC) {
|
103
109
|
log('OIDC enabled, attempting OIDC authentication');
|
104
110
|
const standardAuthorization = request.headers.get('Authorization');
|
105
|
-
const oidcAuthToken = request.headers.get(
|
111
|
+
const oidcAuthToken = request.headers.get(LOBE_CHAT_OIDC_AUTH_HEADER);
|
106
112
|
log('Standard Authorization header: %s', standardAuthorization ? 'exists' : 'not found');
|
107
113
|
log('Oidc-Auth header: %s', oidcAuthToken ? 'exists' : 'not found');
|
108
114
|
|
@@ -73,10 +73,11 @@ export default {
|
|
73
73
|
ImageUpload: {
|
74
74
|
actions: {
|
75
75
|
changeImage: '点击更换图片',
|
76
|
+
dropMultipleFiles: '不支持多上传多个文件,只会使用第一个文件',
|
76
77
|
},
|
77
78
|
placeholder: {
|
78
79
|
primary: '添加图片',
|
79
|
-
secondary: '
|
80
|
+
secondary: '点击或拖拽上传',
|
80
81
|
},
|
81
82
|
},
|
82
83
|
KeyValueEditor: {
|
@@ -111,7 +112,7 @@ export default {
|
|
111
112
|
},
|
112
113
|
MultiImagesUpload: {
|
113
114
|
actions: {
|
114
|
-
uploadMore: '
|
115
|
+
uploadMore: '点击或拖拽上传更多',
|
115
116
|
},
|
116
117
|
modal: {
|
117
118
|
complete: '完成',
|
@@ -121,7 +122,7 @@ export default {
|
|
121
122
|
upload: '上传图片',
|
122
123
|
},
|
123
124
|
placeholder: {
|
124
|
-
primary: '
|
125
|
+
primary: '点击或拖拽上传图片',
|
125
126
|
secondary: '支持多张图片选择',
|
126
127
|
},
|
127
128
|
progress: {
|