@lobehub/lobehub 2.0.0-next.167 → 2.0.0-next.169
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 +50 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/changelog/v1.json +18 -0
- package/package.json +4 -4
- package/packages/file-loaders/src/loaders/text/index.ts +7 -7
- package/packages/file-loaders/src/types.ts +47 -47
- package/src/libs/oidc-provider/provider.ts +2 -73
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 2.0.0-next.169](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.168...v2.0.0-next.169)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2025-12-12**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix CVE errors.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix CVE errors, closes [#10748](https://github.com/lobehub/lobe-chat/issues/10748) ([6591f3c](https://github.com/lobehub/lobe-chat/commit/6591f3c))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
## [Version 2.0.0-next.168](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.167...v2.0.0-next.168)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2025-12-12**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Slove market oidc error.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Slove market oidc error, closes [#10715](https://github.com/lobehub/lobe-chat/issues/10715) ([108d2a7](https://github.com/lobehub/lobe-chat/commit/108d2a7))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
## [Version 2.0.0-next.167](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.166...v2.0.0-next.167)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2025-12-11**</sup>
|
package/README.md
CHANGED
|
@@ -352,7 +352,7 @@ In addition, these plugins are not limited to news aggregation, but can also ext
|
|
|
352
352
|
| [SEO](https://lobechat.com/discover/plugin/SEO)<br/><sup>By **orrenprunckun** on **2025-11-14**</sup> | Enter any URL and keyword and get an On-Page SEO analysis & insights!<br/>`seo` |
|
|
353
353
|
| [Shopping tools](https://lobechat.com/discover/plugin/ShoppingTools)<br/><sup>By **shoppingtools** on **2025-10-27**</sup> | Search for products on eBay & AliExpress, find eBay events & coupons. Get prompt examples.<br/>`shopping` `e-bay` `ali-express` `coupons` |
|
|
354
354
|
|
|
355
|
-
> 📊 Total plugins: [<kbd>**
|
|
355
|
+
> 📊 Total plugins: [<kbd>**37**</kbd>](https://lobechat.com/discover/plugins)
|
|
356
356
|
|
|
357
357
|
<!-- PLUGIN LIST -->
|
|
358
358
|
|
|
@@ -387,8 +387,8 @@ Our marketplace is not just a showcase platform but also a collaborative space.
|
|
|
387
387
|
| Recent Submits | Description |
|
|
388
388
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
389
389
|
| [Turtle Soup Host](https://lobechat.com/discover/assistant/lateral-thinking-puzzle)<br/><sup>By **[CSY2022](https://github.com/CSY2022)** on **2025-06-19**</sup> | A turtle soup host needs to provide the scenario, the complete story (truth of the event), and the key point (the condition for guessing correctly).<br/>`turtle-soup` `reasoning` `interaction` `puzzle` `role-playing` |
|
|
390
|
-
| [Gourmet Reviewer🍟](https://lobechat.com/discover/assistant/food-reviewer)<br/><sup>By **[renhai-lab](https://github.com/renhai-lab)** on **2025-06-17**</sup> | Food critique expert<br/>`gourmet` `review` `writing` |
|
|
391
390
|
| [Academic Writing Assistant](https://lobechat.com/discover/assistant/academic-writing-assistant)<br/><sup>By **[swarfte](https://github.com/swarfte)** on **2025-06-17**</sup> | Expert in academic research paper writing and formal documentation<br/>`academic-writing` `research` `formal-style` |
|
|
391
|
+
| [Gourmet Reviewer🍟](https://lobechat.com/discover/assistant/food-reviewer)<br/><sup>By **[renhai-lab](https://github.com/renhai-lab)** on **2025-06-17**</sup> | Food critique expert<br/>`gourmet` `review` `writing` |
|
|
392
392
|
| [Minecraft Senior Developer](https://lobechat.com/discover/assistant/java-development)<br/><sup>By **[iamyuuk](https://github.com/iamyuuk)** on **2025-06-17**</sup> | Expert in advanced Java development and Minecraft mod and server plugin development<br/>`development` `programming` `minecraft` `java` |
|
|
393
393
|
|
|
394
394
|
> 📊 Total agents: [<kbd>**505**</kbd> ](https://lobechat.com/discover/assistants)
|
package/README.zh-CN.md
CHANGED
|
@@ -345,7 +345,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
345
345
|
| [SEO](https://lobechat.com/discover/plugin/SEO)<br/><sup>By **orrenprunckun** on **2025-11-14**</sup> | 输入任何 URL 和关键词,获取页面 SEO 分析和见解!<br/>`seo` |
|
|
346
346
|
| [购物工具](https://lobechat.com/discover/plugin/ShoppingTools)<br/><sup>By **shoppingtools** on **2025-10-27**</sup> | 在 eBay 和 AliExpress 上搜索产品,查找 eBay 活动和优惠券。获取快速示例。<br/>`购物` `e-bay` `ali-express` `优惠券` |
|
|
347
347
|
|
|
348
|
-
> 📊 Total plugins: [<kbd>**
|
|
348
|
+
> 📊 Total plugins: [<kbd>**37**</kbd>](https://lobechat.com/discover/plugins)
|
|
349
349
|
|
|
350
350
|
<!-- PLUGIN LIST -->
|
|
351
351
|
|
|
@@ -376,8 +376,8 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
376
376
|
| 最近新增 | 描述 |
|
|
377
377
|
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
378
378
|
| [海龟汤主持人](https://lobechat.com/discover/assistant/lateral-thinking-puzzle)<br/><sup>By **[CSY2022](https://github.com/CSY2022)** on **2025-06-19**</sup> | 一个海龟汤主持人,需要自己提供汤面,汤底与关键点(猜中的判定条件)。<br/>`海龟汤` `推理` `互动` `谜题` `角色扮演` |
|
|
379
|
-
| [美食评论员🍟](https://lobechat.com/discover/assistant/food-reviewer)<br/><sup>By **[renhai-lab](https://github.com/renhai-lab)** on **2025-06-17**</sup> | 美食评价专家<br/>`美食` `评价` `写作` |
|
|
380
379
|
| [学术写作助手](https://lobechat.com/discover/assistant/academic-writing-assistant)<br/><sup>By **[swarfte](https://github.com/swarfte)** on **2025-06-17**</sup> | 专业的学术研究论文写作和正式文档编写专家<br/>`学术写作` `研究` `正式风格` |
|
|
380
|
+
| [美食评论员🍟](https://lobechat.com/discover/assistant/food-reviewer)<br/><sup>By **[renhai-lab](https://github.com/renhai-lab)** on **2025-06-17**</sup> | 美食评价专家<br/>`美食` `评价` `写作` |
|
|
381
381
|
| [Minecraft 资深开发者](https://lobechat.com/discover/assistant/java-development)<br/><sup>By **[iamyuuk](https://github.com/iamyuuk)** on **2025-06-17**</sup> | 擅长高级 Java 开发及 Minecraft 开发<br/>`开发` `编程` `minecraft` `java` |
|
|
382
382
|
|
|
383
383
|
> 📊 Total agents: [<kbd>**505**</kbd> ](https://lobechat.com/discover/assistants)
|
package/changelog/v1.json
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"children": {
|
|
4
|
+
"fixes": [
|
|
5
|
+
"Fix CVE errors."
|
|
6
|
+
]
|
|
7
|
+
},
|
|
8
|
+
"date": "2025-12-12",
|
|
9
|
+
"version": "2.0.0-next.169"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"children": {
|
|
13
|
+
"fixes": [
|
|
14
|
+
"Slove market oidc error."
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"date": "2025-12-12",
|
|
18
|
+
"version": "2.0.0-next.168"
|
|
19
|
+
},
|
|
2
20
|
{
|
|
3
21
|
"children": {
|
|
4
22
|
"features": [
|
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.169",
|
|
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",
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
"mdast-util-to-markdown": "^2.1.2",
|
|
244
244
|
"model-bank": "workspace:*",
|
|
245
245
|
"nanoid": "^5.1.6",
|
|
246
|
-
"next": "^16.0.
|
|
246
|
+
"next": "^16.0.10",
|
|
247
247
|
"next-auth": "5.0.0-beta.30",
|
|
248
248
|
"next-mdx-remote": "^5.0.0",
|
|
249
249
|
"nextjs-toploader": "^3.9.17",
|
|
@@ -271,10 +271,10 @@
|
|
|
271
271
|
"query-string": "^9.3.1",
|
|
272
272
|
"random-words": "^2.0.1",
|
|
273
273
|
"rc-util": "^5.44.4",
|
|
274
|
-
"react": "^19.2.
|
|
274
|
+
"react": "^19.2.3",
|
|
275
275
|
"react-confetti": "^6.4.0",
|
|
276
276
|
"react-diff-view": "^3.3.2",
|
|
277
|
-
"react-dom": "^19.2.
|
|
277
|
+
"react-dom": "^19.2.3",
|
|
278
278
|
"react-fast-marquee": "^1.6.5",
|
|
279
279
|
"react-hotkeys-hook": "^5.2.1",
|
|
280
280
|
"react-i18next": "^15.7.4",
|
|
@@ -6,7 +6,7 @@ import type { DocumentPage, FileLoaderInterface } from '../../types';
|
|
|
6
6
|
const log = debug('file-loaders:text');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Loader for loading plain text files.
|
|
10
10
|
*/
|
|
11
11
|
export class TextLoader implements FileLoaderInterface {
|
|
12
12
|
async loadPages(filePath: string): Promise<DocumentPage[]> {
|
|
@@ -35,7 +35,7 @@ export class TextLoader implements FileLoaderInterface {
|
|
|
35
35
|
const error = e as Error;
|
|
36
36
|
log('Error encountered while loading text file');
|
|
37
37
|
console.error(`Error loading text file ${filePath}: ${error.message}`);
|
|
38
|
-
//
|
|
38
|
+
// If reading fails, return a Page containing error information
|
|
39
39
|
const errorPage: DocumentPage = {
|
|
40
40
|
charCount: 0,
|
|
41
41
|
lineCount: 0,
|
|
@@ -50,14 +50,14 @@ export class TextLoader implements FileLoaderInterface {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @param pages
|
|
56
|
-
* @returns
|
|
53
|
+
* For plain text, simply concatenate the content of all pages.
|
|
54
|
+
* (Although TextLoader typically has only one page, this maintains interface consistency)
|
|
55
|
+
* @param pages Array of pages
|
|
56
|
+
* @returns Aggregated content
|
|
57
57
|
*/
|
|
58
58
|
async aggregateContent(pages: DocumentPage[]): Promise<string> {
|
|
59
59
|
log('Aggregating content from', pages.length, 'text pages');
|
|
60
|
-
//
|
|
60
|
+
// By default, join with newline separator, can be adjusted or made configurable as needed
|
|
61
61
|
const result = pages.map((page) => page.pageContent).join('\n');
|
|
62
62
|
log('Content aggregated successfully, length:', result.length);
|
|
63
63
|
return result;
|
|
@@ -2,199 +2,199 @@
|
|
|
2
2
|
export type SupportedFileType = 'pdf' | 'doc' | 'docx' | 'txt' | 'excel' | 'pptx'; // | 'pptx' | 'latex' | 'epub' | 'code' | 'markdown';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Represents a complete loaded file, including file-level information and all its pages/chunks.
|
|
6
6
|
*/
|
|
7
7
|
export interface FileDocument {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* File content
|
|
10
10
|
*/
|
|
11
11
|
content: string;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* File creation timestamp.
|
|
15
15
|
*/
|
|
16
16
|
createdTime: Date;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* File type or extension.
|
|
20
20
|
*/
|
|
21
21
|
fileType: string;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Original filename.
|
|
25
25
|
*/
|
|
26
26
|
filename: string;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* File-level metadata.
|
|
30
|
+
* For example, title and author extracted from file properties, or errors when the entire file loading fails.
|
|
31
31
|
*/
|
|
32
32
|
metadata: {
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Allows adding other file-level metadata.
|
|
35
35
|
*/
|
|
36
36
|
[key: string]: any;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Document author (if available).
|
|
39
39
|
*/
|
|
40
40
|
author?: string;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* If the entire file loading fails, record error information.
|
|
43
43
|
*/
|
|
44
44
|
error?: string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Document title (if available).
|
|
47
47
|
*/
|
|
48
48
|
title?: string;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* File last modified timestamp.
|
|
53
53
|
*/
|
|
54
54
|
modifiedTime: Date;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* Array containing all logical pages/chunks in the document.
|
|
58
|
+
* The order typically corresponds to the natural order in the file.
|
|
59
59
|
*/
|
|
60
60
|
pages?: DocumentPage[];
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Full path of the original file.
|
|
64
64
|
*/
|
|
65
65
|
source: string;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
* Total character count of the entire document (sum of all Page charCounts).
|
|
69
|
+
* Needs to be calculated after all Pages are loaded and computed.
|
|
70
70
|
*/
|
|
71
71
|
totalCharCount: number;
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
74
|
+
* Total line count of the entire document (sum of all Page lineCounts).
|
|
75
|
+
* Needs to be calculated after all Pages are loaded and computed.
|
|
76
76
|
*/
|
|
77
77
|
totalLineCount: number;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* Represents a logical unit/page/chunk in a file.
|
|
82
82
|
*/
|
|
83
83
|
export interface DocumentPage {
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* Character count of this page/chunk content.
|
|
86
86
|
*/
|
|
87
87
|
charCount: number;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
90
|
+
* Line count of this page/chunk content.
|
|
91
91
|
*/
|
|
92
92
|
lineCount: number;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
95
|
+
* Metadata related to this page/chunk.
|
|
96
96
|
*/
|
|
97
97
|
metadata: {
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
99
|
+
* Allows adding other page/chunk-specific metadata.
|
|
100
100
|
*/
|
|
101
101
|
[key: string]: any;
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* If the original file unit is further divided into chunks, this is the index of the current chunk.
|
|
105
105
|
*/
|
|
106
106
|
chunkIndex?: number;
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
109
|
+
* Error that occurred when processing this page/chunk.
|
|
110
110
|
*/
|
|
111
111
|
error?: string;
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* Ending line number of this page/chunk in the original file.
|
|
115
115
|
*/
|
|
116
116
|
lineNumberEnd?: number;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
119
|
+
* Starting line number of this page/chunk in the original file.
|
|
120
120
|
*/
|
|
121
121
|
lineNumberStart?: number;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
124
|
+
* Page number (applicable for PDF, DOCX).
|
|
125
125
|
*/
|
|
126
126
|
pageNumber?: number;
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* Section title related to this page/chunk.
|
|
130
130
|
*/
|
|
131
131
|
sectionTitle?: string;
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
134
|
+
* Sheet name (applicable for XLSX).
|
|
135
135
|
*/
|
|
136
136
|
sheetName?: string;
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* Slide number (applicable for PPTX).
|
|
140
140
|
*/
|
|
141
141
|
slideNumber?: number;
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* If the original file unit is further divided into chunks, this is the total number of chunks for that unit.
|
|
145
145
|
*/
|
|
146
146
|
totalChunks?: number;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
150
|
+
* Core text content of this page/chunk.
|
|
151
151
|
*/
|
|
152
152
|
pageContent: string;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
|
-
*
|
|
156
|
+
* Optional file metadata used to override information read from the filesystem.
|
|
157
157
|
*/
|
|
158
158
|
export interface FileMetadata {
|
|
159
159
|
/**
|
|
160
|
-
*
|
|
160
|
+
* File creation timestamp.
|
|
161
161
|
*/
|
|
162
162
|
createdTime?: Date;
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
164
|
+
* File type or extension.
|
|
165
165
|
*/
|
|
166
166
|
fileType?: string;
|
|
167
167
|
/**
|
|
168
|
-
*
|
|
168
|
+
* Filename.
|
|
169
169
|
*/
|
|
170
170
|
filename?: string;
|
|
171
171
|
/**
|
|
172
|
-
*
|
|
172
|
+
* File last modified timestamp.
|
|
173
173
|
*/
|
|
174
174
|
modifiedTime?: Date;
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
176
|
+
* File source identifier (e.g., S3 URL or original path).
|
|
177
177
|
*/
|
|
178
178
|
source?: string;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
182
|
+
* Defines the interface that all file loader classes must implement.
|
|
183
183
|
*/
|
|
184
184
|
export interface FileLoaderInterface {
|
|
185
185
|
/**
|
|
186
|
-
*
|
|
187
|
-
* @param pages DocumentPage
|
|
188
|
-
* @returns
|
|
186
|
+
* Aggregates the page content obtained from loadPages into a single string.
|
|
187
|
+
* @param pages Array of DocumentPage objects.
|
|
188
|
+
* @returns Promise that returns the aggregated text content.
|
|
189
189
|
*/
|
|
190
190
|
aggregateContent(pages: DocumentPage[]): Promise<string>;
|
|
191
191
|
|
|
192
192
|
attachDocumentMetadata?(filePath: string): Promise<Record<string, any>>;
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
196
|
-
* @param filePath
|
|
197
|
-
* @returns
|
|
195
|
+
* Loads file content based on the file path and splits it into logical pages/chunks.
|
|
196
|
+
* @param filePath Full path of the file.
|
|
197
|
+
* @returns Promise that returns an array containing DocumentPage objects.
|
|
198
198
|
*/
|
|
199
199
|
loadPages(filePath: string): Promise<DocumentPage[]>;
|
|
200
200
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { EmailAddress } from '@clerk/backend';
|
|
2
1
|
import { LobeChatDatabase } from '@lobechat/database';
|
|
3
2
|
import debug from 'debug';
|
|
4
3
|
import Provider, { Configuration, KoaContextWithOIDC, errors } from 'oidc-provider';
|
|
5
4
|
import urlJoin from 'url-join';
|
|
6
5
|
|
|
7
6
|
import { serverDBEnv } from '@/config/db';
|
|
8
|
-
import { enableClerk } from '@/const/auth';
|
|
9
7
|
import { UserModel } from '@/database/models/user';
|
|
10
8
|
import { appEnv } from '@/envs/app';
|
|
11
9
|
import { getJWKS } from '@/libs/oidc-provider/jwt';
|
|
@@ -15,59 +13,9 @@ import { DrizzleAdapter } from './adapter';
|
|
|
15
13
|
import { defaultClaims, defaultClients, defaultScopes } from './config';
|
|
16
14
|
import { createInteractionPolicy } from './interaction-policy';
|
|
17
15
|
|
|
18
|
-
const logProvider = debug('lobe-oidc:provider');
|
|
16
|
+
const logProvider = debug('lobe-oidc:provider');
|
|
19
17
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const resolveClerkAccount = async (accountId: string) => {
|
|
23
|
-
if (!enableClerk) return undefined;
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const { clerkClient } = await import('@clerk/nextjs/server');
|
|
27
|
-
const client = await clerkClient();
|
|
28
|
-
const user = await client.users.getUser(accountId);
|
|
29
|
-
|
|
30
|
-
if (!user) {
|
|
31
|
-
logProvider('Clerk user not found for accountId: %s', accountId);
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const pickName = () =>
|
|
36
|
-
user.fullName ||
|
|
37
|
-
[user.firstName, user.lastName].filter(Boolean).join(' ').trim() ||
|
|
38
|
-
user.username ||
|
|
39
|
-
user.id;
|
|
40
|
-
|
|
41
|
-
const primaryEmail = user.primaryEmailAddressId
|
|
42
|
-
? user.emailAddresses.find((item: EmailAddress) => item.id === user.primaryEmailAddressId)
|
|
43
|
-
: user.emailAddresses.at(0);
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
accountId: user.id,
|
|
47
|
-
async claims(_use: string, scope: string) {
|
|
48
|
-
const scopeSet = new Set((scope || '').split(/\s+/).filter(Boolean));
|
|
49
|
-
const claims: { [key: string]: any; sub: string } = { sub: user.id };
|
|
50
|
-
|
|
51
|
-
if (scopeSet.has('profile')) {
|
|
52
|
-
claims.name = pickName();
|
|
53
|
-
if (user.imageUrl) claims.picture = user.imageUrl;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (scopeSet.has('email') && primaryEmail) {
|
|
57
|
-
claims.email = primaryEmail.emailAddress;
|
|
58
|
-
claims.email_verified = primaryEmail.verification?.status === 'verified' || false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return claims;
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
} catch (error) {
|
|
65
|
-
logProvider('Error resolving Clerk account for %s: %O', accountId, error);
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const API_AUDIENCE = 'urn:lobehub:chat'; // <-- 把这里换成你自己的 API 标识符
|
|
18
|
+
export const API_AUDIENCE = 'urn:lobehub:chat';
|
|
71
19
|
|
|
72
20
|
/**
|
|
73
21
|
* 获取 Cookie 密钥,使用 KEY_VAULTS_SECRET
|
|
@@ -190,25 +138,6 @@ export const createOIDCProvider = async (db: LobeChatDatabase): Promise<Provider
|
|
|
190
138
|
|
|
191
139
|
logProvider('OIDC request client id: %s', clientId);
|
|
192
140
|
|
|
193
|
-
if (clientId === MARKET_CLIENT_ID) {
|
|
194
|
-
logProvider('Using Clerk account resolution for marketplace client');
|
|
195
|
-
|
|
196
|
-
if (!accountIdToFind) {
|
|
197
|
-
logProvider('No account id available for Clerk resolution, returning undefined');
|
|
198
|
-
return undefined;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const clerkAccount = await resolveClerkAccount(accountIdToFind);
|
|
202
|
-
|
|
203
|
-
if (clerkAccount) {
|
|
204
|
-
logProvider('Clerk account resolved successfully for %s', accountIdToFind);
|
|
205
|
-
return clerkAccount;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
logProvider('Clerk account resolution failed for %s', accountIdToFind);
|
|
209
|
-
return undefined;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
141
|
logProvider(
|
|
213
142
|
'Attempting to find account with ID: %s (source: %s)',
|
|
214
143
|
accountIdToFind,
|