@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.
Files changed (59) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +2 -2
  3. package/README.zh-CN.md +2 -2
  4. package/changelog/v1.json +21 -0
  5. package/docs/development/basic/add-new-ai-image-model.mdx +36 -0
  6. package/docs/development/basic/add-new-ai-image-model.zh-CN.mdx +0 -0
  7. package/locales/ar/components.json +5 -4
  8. package/locales/ar/models.json +3 -0
  9. package/locales/bg-BG/components.json +5 -4
  10. package/locales/bg-BG/models.json +3 -0
  11. package/locales/de-DE/components.json +5 -4
  12. package/locales/de-DE/models.json +3 -0
  13. package/locales/en-US/components.json +5 -4
  14. package/locales/en-US/models.json +3 -0
  15. package/locales/es-ES/components.json +5 -4
  16. package/locales/es-ES/models.json +3 -0
  17. package/locales/fa-IR/components.json +5 -4
  18. package/locales/fa-IR/models.json +3 -0
  19. package/locales/fr-FR/components.json +5 -4
  20. package/locales/fr-FR/models.json +3 -0
  21. package/locales/it-IT/components.json +5 -4
  22. package/locales/it-IT/models.json +3 -0
  23. package/locales/ja-JP/components.json +5 -4
  24. package/locales/ja-JP/models.json +3 -0
  25. package/locales/ko-KR/components.json +5 -4
  26. package/locales/ko-KR/models.json +3 -0
  27. package/locales/nl-NL/components.json +5 -4
  28. package/locales/nl-NL/models.json +3 -0
  29. package/locales/pl-PL/components.json +5 -4
  30. package/locales/pl-PL/models.json +3 -0
  31. package/locales/pt-BR/components.json +5 -4
  32. package/locales/pt-BR/models.json +3 -0
  33. package/locales/ru-RU/components.json +5 -4
  34. package/locales/ru-RU/models.json +3 -0
  35. package/locales/tr-TR/components.json +5 -4
  36. package/locales/tr-TR/models.json +3 -0
  37. package/locales/vi-VN/components.json +5 -4
  38. package/locales/vi-VN/models.json +3 -0
  39. package/locales/zh-CN/components.json +5 -4
  40. package/locales/zh-CN/models.json +3 -0
  41. package/locales/zh-TW/components.json +5 -4
  42. package/locales/zh-TW/models.json +3 -0
  43. package/package.json +1 -1
  44. package/src/app/(backend)/middleware/auth/index.ts +28 -7
  45. package/src/app/[variants]/(main)/image/@menu/components/SeedNumberInput/index.tsx +24 -9
  46. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/DimensionControlGroup.tsx +0 -1
  47. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ImageUpload.tsx +161 -39
  48. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/MultiImagesUpload/ImageManageModal.tsx +10 -10
  49. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/MultiImagesUpload/index.tsx +153 -83
  50. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/SeedNumberInput.tsx +2 -11
  51. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/hooks/useDragAndDrop.ts +71 -0
  52. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/style.ts +17 -0
  53. package/src/config/aiModels/zhipu.ts +29 -6
  54. package/src/const/auth.ts +1 -0
  55. package/src/libs/model-runtime/utils/openaiCompatibleFactory/index.test.ts +20 -3
  56. package/src/libs/model-runtime/utils/openaiCompatibleFactory/index.ts +20 -11
  57. package/src/libs/oidc-provider/jwt.ts +22 -13
  58. package/src/libs/trpc/lambda/context.ts +8 -2
  59. 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
- // 查找 RS256 算法的 RSA 密钥
62
- const rsaKey = jwks.keys.find((key: any) => key.alg === 'RS256' && key.kty === 'RSA');
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
- // 导入 JWK 为公钥
69
- const publicKey = await importJWK(rsaKey, 'RS256');
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
- return publicKey;
79
+ // 现在,无论在哪个环境下,`importJWK` 都会将这个对象正确地识别为一个公钥。
80
+ return await importJWK(publicKeyJwk, 'RS256');
72
81
  } catch (error) {
73
82
  log('获取 JWKS 公钥失败: %O', error);
74
- throw new Error(`JWKS 公钥获取失败: ${(error as Error).message}`);
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 getJWKSPublicKey();
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 { JWTPayload, LOBE_CHAT_AUTH_HEADER, enableClerk, enableNextAuth } from '@/const/auth';
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('Oidc-Auth');
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: {