@lobehub/chat 0.124.3 → 0.125.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 +25 -0
- package/README.md +8 -8
- package/README.zh-CN.md +8 -8
- package/docs/Deployment/Authentication.md +72 -0
- package/docs/Deployment/Authentication.zh-CN.md +72 -0
- package/docs/Deployment/Environment-Variable.md +50 -0
- package/docs/Deployment/Environment-Variable.zh-CN.md +50 -0
- package/docs/Development/Authentication.md +85 -0
- package/docs/Development/Authentication.zh-CN.md +83 -0
- package/locales/ar/common.json +1 -0
- package/locales/ar/error.json +6 -0
- package/locales/ar/setting.json +16 -0
- package/locales/de-DE/common.json +1 -0
- package/locales/de-DE/error.json +6 -0
- package/locales/de-DE/setting.json +16 -0
- package/locales/en-US/common.json +1 -0
- package/locales/en-US/error.json +6 -0
- package/locales/en-US/setting.json +16 -0
- package/locales/es-ES/common.json +1 -0
- package/locales/es-ES/error.json +6 -0
- package/locales/es-ES/setting.json +16 -0
- package/locales/fr-FR/common.json +1 -0
- package/locales/fr-FR/error.json +6 -0
- package/locales/fr-FR/setting.json +16 -0
- package/locales/it-IT/common.json +1 -0
- package/locales/it-IT/error.json +6 -0
- package/locales/it-IT/setting.json +16 -0
- package/locales/ja-JP/common.json +1 -0
- package/locales/ja-JP/error.json +6 -0
- package/locales/ja-JP/setting.json +16 -0
- package/locales/ko-KR/common.json +1 -0
- package/locales/ko-KR/error.json +6 -0
- package/locales/ko-KR/setting.json +16 -0
- package/locales/nl-NL/common.json +1 -0
- package/locales/nl-NL/error.json +6 -0
- package/locales/nl-NL/setting.json +16 -0
- package/locales/pl-PL/common.json +1 -0
- package/locales/pl-PL/error.json +6 -0
- package/locales/pl-PL/setting.json +16 -0
- package/locales/pt-BR/common.json +1 -0
- package/locales/pt-BR/error.json +6 -0
- package/locales/pt-BR/setting.json +16 -0
- package/locales/ru-RU/common.json +1 -0
- package/locales/ru-RU/error.json +6 -0
- package/locales/ru-RU/setting.json +16 -0
- package/locales/tr-TR/common.json +1 -0
- package/locales/tr-TR/error.json +6 -0
- package/locales/tr-TR/setting.json +16 -0
- package/locales/vi-VN/common.json +1 -0
- package/locales/vi-VN/error.json +6 -0
- package/locales/vi-VN/setting.json +16 -0
- package/locales/zh-CN/common.json +1 -0
- package/locales/zh-CN/error.json +6 -0
- package/locales/zh-CN/setting.json +16 -0
- package/locales/zh-TW/common.json +1 -0
- package/locales/zh-TW/error.json +6 -0
- package/locales/zh-TW/setting.json +16 -0
- package/package.json +2 -1
- package/src/app/api/auth.ts +7 -1
- package/src/app/api/chat/[provider]/route.ts +5 -3
- package/src/app/api/chat/auth.ts +11 -3
- package/src/app/api/chat/google/route.ts +5 -3
- package/src/app/api/config/route.ts +9 -2
- package/src/app/api/oauth/[...nextauth]/route.ts +3 -0
- package/src/app/api/oauth/next-auth.ts +21 -0
- package/src/app/api/openai/createBizOpenAI/index.ts +3 -2
- package/src/app/api/plugin/gateway/route.ts +7 -4
- package/src/app/settings/common/Common.tsx +39 -1
- package/src/app/settings/common/page.tsx +2 -2
- package/src/app/settings/page.tsx +2 -2
- package/src/chains/summaryTitle.ts +1 -1
- package/src/config/server/app.ts +5 -0
- package/src/const/auth.ts +2 -0
- package/src/const/fetch.ts +5 -1
- package/src/features/ChatInput/ActionBar/Clear.tsx +6 -8
- package/src/features/Conversation/Error/InvalidAccessCode.tsx +28 -10
- package/src/features/Conversation/Error/OAuthForm.tsx +95 -0
- package/src/layout/GlobalLayout/index.tsx +10 -7
- package/src/locales/default/common.ts +1 -0
- package/src/locales/default/error.ts +6 -0
- package/src/locales/default/setting.ts +16 -0
- package/src/middleware.ts +25 -0
- package/src/store/global/slices/common/initialState.ts +0 -1
- package/src/store/global/slices/common/selectors.ts +1 -0
- package/src/types/settings/index.ts +1 -0
- package/tsconfig.json +8 -8
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// export { auth as middleware } from './app/api/next-auth';
|
|
2
|
+
import { NextResponse } from 'next/server';
|
|
3
|
+
|
|
4
|
+
import { auth } from './app/api/oauth/next-auth';
|
|
5
|
+
import { OAUTH_AUTHORIZED } from './const/auth';
|
|
6
|
+
|
|
7
|
+
export const config = {
|
|
8
|
+
matcher: '/api/:path*',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default auth((req) => {
|
|
12
|
+
// Just check if session exists
|
|
13
|
+
const session = req.auth;
|
|
14
|
+
const isLoggedIn = !!session;
|
|
15
|
+
|
|
16
|
+
// Remove & amend OAuth authorized header
|
|
17
|
+
const requestHeaders = new Headers(req.headers);
|
|
18
|
+
requestHeaders.delete(OAUTH_AUTHORIZED);
|
|
19
|
+
if (isLoggedIn) requestHeaders.set(OAUTH_AUTHORIZED, 'true');
|
|
20
|
+
return NextResponse.next({
|
|
21
|
+
request: {
|
|
22
|
+
headers: requestHeaders,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"types": ["vitest/globals"],
|
|
20
20
|
"paths": {
|
|
21
21
|
"@/*": ["./src/*"],
|
|
22
|
-
"~test-utils": ["./tests/utils.tsx"]
|
|
22
|
+
"~test-utils": ["./tests/utils.tsx"]
|
|
23
23
|
},
|
|
24
24
|
"plugins": [
|
|
25
25
|
{
|
|
26
|
-
"name": "next"
|
|
27
|
-
}
|
|
28
|
-
]
|
|
26
|
+
"name": "next"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
29
|
},
|
|
30
30
|
"exclude": ["node_modules"],
|
|
31
31
|
"include": [
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"**/*.ts",
|
|
37
37
|
"**/*.d.ts",
|
|
38
38
|
"**/*.tsx",
|
|
39
|
-
".next/types/**/*.ts"
|
|
39
|
+
".next/types/**/*.ts"
|
|
40
40
|
],
|
|
41
41
|
"ts-node": {
|
|
42
42
|
"compilerOptions": {
|
|
43
|
-
"module": "commonjs"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
43
|
+
"module": "commonjs"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
46
|
}
|