Spaces:
Running
Running
Upload 14 files
Browse files- .env.example +20 -0
- .gitattributes +1 -0
- .gitignore +34 -0
- Dockerfile +24 -0
- README.md +128 -10
- package-lock.json +2044 -0
- package.json +37 -0
- src/CookieManager.js +423 -0
- src/ProxyPool.js +630 -0
- src/ProxyServer.js +204 -0
- src/cookie-cli.js +301 -0
- src/lightweight-client-express.js +341 -0
- src/lightweight-client.js +856 -0
- src/models.js +213 -0
- src/proxy/chrome_proxy_server_linux_amd64 +3 -0
.env.example
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# (必选)Notion的cookie,请把浏览器Cookie部分完整复制下来,多个cookie用|分割
|
2 |
+
NOTION_COOKIE="cookie1|cookie2"
|
3 |
+
# (可选)cookie文件路径,每行一个cookie,如果找不到文件,会尝试在环境变量中查找
|
4 |
+
#COOKIE_FILE="./cookies.txt"
|
5 |
+
# (可选)反代密码,没有的话默认密码是 default_token
|
6 |
+
PROXY_AUTH_TOKEN="sk-text"
|
7 |
+
# (可选)代理地址,启用tls后失效
|
8 |
+
PROXY_URL=""
|
9 |
+
# (可选)是否使用本地代理池,启用前确保没有设置其它代理,否则速度会减慢或者出现其它问题,推荐启用
|
10 |
+
USE_NATIVE_PROXY_POOL=true
|
11 |
+
|
12 |
+
# tls代理服务器配置(可选)建议启用
|
13 |
+
# 平台选择:auto(自动检测), windows, linux, android
|
14 |
+
PROXY_SERVER_PLATFORM="auto"
|
15 |
+
# tls代理服务器端口
|
16 |
+
PROXY_SERVER_PORT=10655
|
17 |
+
# tls代理服务器日志文件路径
|
18 |
+
PROXY_SERVER_LOG_PATH="./proxy_server.log"
|
19 |
+
# 是否启用tls代理服务器
|
20 |
+
ENABLE_PROXY_SERVER=true
|
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
src/proxy/chrome_proxy_server_linux_amd64 filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 依赖
|
2 |
+
node_modules/
|
3 |
+
npm-debug.log
|
4 |
+
yarn-debug.log
|
5 |
+
yarn-error.log
|
6 |
+
|
7 |
+
# 环境变量
|
8 |
+
.env
|
9 |
+
.env.local
|
10 |
+
.env.development.local
|
11 |
+
.env.test.local
|
12 |
+
.env.production.local
|
13 |
+
|
14 |
+
# 日志
|
15 |
+
logs
|
16 |
+
*.log
|
17 |
+
|
18 |
+
# 运行时数据
|
19 |
+
pids
|
20 |
+
*.pid
|
21 |
+
*.seed
|
22 |
+
*.pid.lock
|
23 |
+
|
24 |
+
# 目录
|
25 |
+
dist/
|
26 |
+
build/
|
27 |
+
coverage/
|
28 |
+
|
29 |
+
# 其他
|
30 |
+
.DS_Store
|
31 |
+
.idea/
|
32 |
+
.vscode/
|
33 |
+
*.swp
|
34 |
+
*.swo
|
Dockerfile
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 使用官方 Node.js 18 slim 镜像作为基础
|
2 |
+
FROM node:18-slim
|
3 |
+
|
4 |
+
# 设置工作目录
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# 复制 package.json 和 package-lock.json
|
8 |
+
COPY package*.json ./
|
9 |
+
|
10 |
+
# 安装项目依赖
|
11 |
+
# 我们只安装生产环境需要的包,以减小镜像体积
|
12 |
+
RUN npm install --production
|
13 |
+
|
14 |
+
# 复制项目源代码
|
15 |
+
COPY . .
|
16 |
+
|
17 |
+
# 确保代理服务器可执行 (Hugging Face Spaces 通常运行在 linux/amd64 架构上)
|
18 |
+
RUN chmod +x src/proxy/chrome_proxy_server_linux_amd64
|
19 |
+
|
20 |
+
# 暴露应用端口 (Hugging Face 会自动映射)
|
21 |
+
EXPOSE 7860
|
22 |
+
|
23 |
+
# 启动应用
|
24 |
+
CMD ["npm", "start"]
|
README.md
CHANGED
@@ -1,10 +1,128 @@
|
|
1 |
-
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
-
sdk: docker
|
7 |
-
|
8 |
-
---
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Notion
|
3 |
+
emoji: 📝
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: blue
|
6 |
+
sdk: docker
|
7 |
+
app_port: 7860
|
8 |
+
---
|
9 |
+
|
10 |
+
# Notion API 轻量级客户端 (Hugging Face Space)
|
11 |
+
|
12 |
+
这个项目提供了一个轻量级的 Notion API 客户端,可以作为 Web 服务部署在 Hugging Face Spaces 上。它兼容 OpenAI API 格式,让你可以将 Notion AI 作为后端集成到各种应用中。
|
13 |
+
|
14 |
+
## 🚀 在 Hugging Face Spaces 上部署
|
15 |
+
|
16 |
+
1. **创建 Space**: 在 Hugging Face 上创建一个新的 Space。
|
17 |
+
2. **选择 Docker SDK**: 在 "Choose an SDK" 步骤中,选择 "Docker"。
|
18 |
+
3. **上传文件**: 将此项目的所有文件(包括 `Dockerfile`)上传到你的 Space Git 仓库中。
|
19 |
+
4. **设置 Secrets**: 这是最重要的一步。你的 Notion 凭证和其他配置需要作为 Secrets 添加到 Space 中。进入你的 Space "Settings" 页面,找到 "Repository secrets" 部分,然后点击 "New secret" 添加以下变量:
|
20 |
+
|
21 |
+
* **必需**:
|
22 |
+
* `NOTION_COOKIE`: 你的 Notion Cookie。你可以通过浏览器开发者工具获取。
|
23 |
+
* **可选**:
|
24 |
+
* `NOTION_SPACE_ID`: 你的 Notion Space ID。
|
25 |
+
* `NOTION_ACTIVE_USER_HEADER`: 你的 Notion 用户 ID。
|
26 |
+
* `PROXY_URL`: 如果你需要通过代理访问 Notion,请设置此项 (例如 `http://user:pass@host:port`)。
|
27 |
+
* `PROXY_AUTH_TOKEN`: 如果你的代理需要单独的认证令牌,请设置此项。
|
28 |
+
* `COOKIE_FILE`: 如果你使用文件管理多个 Cookie,请设置为文件名 (例如 `cookies.txt`)。请确保该文件也已上传到仓库中。
|
29 |
+
|
30 |
+
**注意**: `PORT` 环境变量由 Hugging Face 自动处理,你无需设置。
|
31 |
+
|
32 |
+
5. **等待部署**: 添加完 Secrets 后,Hugging Face 会自动构建 Docker 镜像并部署你的应用。你可以在 "Logs" 标签页查看部署进度和应用日志。部署成功后,你的 API 端点即可使用。
|
33 |
+
|
34 |
+
## 📖 API 使用说明
|
35 |
+
|
36 |
+
服务启动后,你可以通过你的 Space URL 访问 API。
|
37 |
+
|
38 |
+
**基础 URL**: `https://<your-space-name>.hf.space`
|
39 |
+
|
40 |
+
### API 端点
|
41 |
+
|
42 |
+
- `GET /v1/models` - 获取可用模型列表 (主要是为了兼容 OpenAI 客户端)
|
43 |
+
- `POST /v1/chat/completions` - 核心的聊天完成端点
|
44 |
+
- `GET /health` - 健康检查端点
|
45 |
+
|
46 |
+
### 示例: 使用 cURL 调用
|
47 |
+
|
48 |
+
```bash
|
49 |
+
curl -X POST https://<your-space-name>.hf.space/v1/chat/completions \
|
50 |
+
-H "Content-Type: application/json" \
|
51 |
+
-d '{
|
52 |
+
"model": "openai-gpt-4.1",
|
53 |
+
"messages": [
|
54 |
+
{"role": "user", "content": "你好,请介绍一下你自己"}
|
55 |
+
],
|
56 |
+
"stream": true
|
57 |
+
}'
|
58 |
+
```
|
59 |
+
*请将 `<your-space-name>` 替换为你的 Space 名称。*
|
60 |
+
|
61 |
+
## 🍪 Cookie 管理
|
62 |
+
|
63 |
+
为了提高服务的稳定性,你可以提供多个 Notion Cookie。
|
64 |
+
|
65 |
+
### 通过文件管理 Cookie
|
66 |
+
|
67 |
+
1. 在项目根目录创建一个 `cookies.txt` 或 `cookies.json` 文件。
|
68 |
+
2. 将文件上传到你的 Space 仓库。
|
69 |
+
3. 在 Space Secrets 中设置 `COOKIE_FILE` 为你的文件名 (例如 `cookies.txt`)。
|
70 |
+
|
71 |
+
系统启动时会自动从该文件加载Cookie。
|
72 |
+
|
73 |
+
**`cookies.txt` 示例:** (每行一个Cookie)
|
74 |
+
```
|
75 |
+
cookie1_string_here
|
76 |
+
cookie2_string_here
|
77 |
+
```
|
78 |
+
|
79 |
+
**`cookies.json` 示例:**
|
80 |
+
```json
|
81 |
+
{
|
82 |
+
"cookies": [
|
83 |
+
"cookie1_string_here",
|
84 |
+
"cookie2_string_here"
|
85 |
+
]
|
86 |
+
}
|
87 |
+
```
|
88 |
+
|
89 |
+
### Cookie 轮询机制
|
90 |
+
|
91 |
+
系统会自动轮询使用所有有效的Cookie。当一个Cookie失效时(例如返回401错误),会自动切换到下一个有效的Cookie,确保服务不中断。
|
92 |
+
|
93 |
+
---
|
94 |
+
|
95 |
+
## 本地开发参考
|
96 |
+
|
97 |
+
以下信息用于在本地计算机上运行和开发。
|
98 |
+
|
99 |
+
### 依赖项
|
100 |
+
```bash
|
101 |
+
npm install
|
102 |
+
```
|
103 |
+
|
104 |
+
### 环境变量
|
105 |
+
创建 `.env` 文件,设置以下环境变量:
|
106 |
+
```
|
107 |
+
NOTION_COOKIE=your_notion_cookie_here
|
108 |
+
NOTION_SPACE_ID=optional_space_id
|
109 |
+
NOTION_ACTIVE_USER_HEADER=optional_user_id
|
110 |
+
PROXY_URL=optional_proxy_url
|
111 |
+
PROXY_AUTH_TOKEN=your_auth_token
|
112 |
+
PORT=7860
|
113 |
+
```
|
114 |
+
|
115 |
+
### 启动服务
|
116 |
+
```bash
|
117 |
+
npm start
|
118 |
+
```
|
119 |
+
|
120 |
+
### Cookie 管理命令行工具
|
121 |
+
项目提供了一个命令行工具来方便地管理 `cookies.json` 文件。
|
122 |
+
```bash
|
123 |
+
# 运行命令行工具
|
124 |
+
npm run cookie
|
125 |
+
|
126 |
+
# 支持的命令
|
127 |
+
help, list, add, validate, remove, save, load, exit
|
128 |
+
```
|
package-lock.json
ADDED
@@ -0,0 +1,2044 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
"axios": "^1.9.0",
|
13 |
+
"chalk": "^4.1.2",
|
14 |
+
"dotenv": "^16.3.1",
|
15 |
+
"express": "^4.18.2",
|
16 |
+
"https-proxy-agent": "^7.0.2",
|
17 |
+
"jsdom": "^22.1.0",
|
18 |
+
"node-fetch": "^3.3.2",
|
19 |
+
"playwright": "^1.40.1"
|
20 |
+
},
|
21 |
+
"bin": {
|
22 |
+
"notion-cookie": "src/cookie-cli.js"
|
23 |
+
},
|
24 |
+
"devDependencies": {
|
25 |
+
"nodemon": "^3.0.2"
|
26 |
+
}
|
27 |
+
},
|
28 |
+
"node_modules/@tootallnate/once": {
|
29 |
+
"version": "2.0.0",
|
30 |
+
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
|
31 |
+
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
|
32 |
+
"license": "MIT",
|
33 |
+
"engines": {
|
34 |
+
"node": ">= 10"
|
35 |
+
}
|
36 |
+
},
|
37 |
+
"node_modules/abab": {
|
38 |
+
"version": "2.0.6",
|
39 |
+
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz",
|
40 |
+
"integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==",
|
41 |
+
"deprecated": "Use your platform's native atob() and btoa() methods instead",
|
42 |
+
"license": "BSD-3-Clause"
|
43 |
+
},
|
44 |
+
"node_modules/accepts": {
|
45 |
+
"version": "1.3.8",
|
46 |
+
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
47 |
+
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
48 |
+
"license": "MIT",
|
49 |
+
"dependencies": {
|
50 |
+
"mime-types": "~2.1.34",
|
51 |
+
"negotiator": "0.6.3"
|
52 |
+
},
|
53 |
+
"engines": {
|
54 |
+
"node": ">= 0.6"
|
55 |
+
}
|
56 |
+
},
|
57 |
+
"node_modules/agent-base": {
|
58 |
+
"version": "7.1.3",
|
59 |
+
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
|
60 |
+
"integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==",
|
61 |
+
"license": "MIT",
|
62 |
+
"engines": {
|
63 |
+
"node": ">= 14"
|
64 |
+
}
|
65 |
+
},
|
66 |
+
"node_modules/ansi-styles": {
|
67 |
+
"version": "4.3.0",
|
68 |
+
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
69 |
+
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
70 |
+
"license": "MIT",
|
71 |
+
"dependencies": {
|
72 |
+
"color-convert": "^2.0.1"
|
73 |
+
},
|
74 |
+
"engines": {
|
75 |
+
"node": ">=8"
|
76 |
+
},
|
77 |
+
"funding": {
|
78 |
+
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
79 |
+
}
|
80 |
+
},
|
81 |
+
"node_modules/anymatch": {
|
82 |
+
"version": "3.1.3",
|
83 |
+
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
|
84 |
+
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
|
85 |
+
"dev": true,
|
86 |
+
"license": "ISC",
|
87 |
+
"dependencies": {
|
88 |
+
"normalize-path": "^3.0.0",
|
89 |
+
"picomatch": "^2.0.4"
|
90 |
+
},
|
91 |
+
"engines": {
|
92 |
+
"node": ">= 8"
|
93 |
+
}
|
94 |
+
},
|
95 |
+
"node_modules/array-flatten": {
|
96 |
+
"version": "1.1.1",
|
97 |
+
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
98 |
+
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
99 |
+
"license": "MIT"
|
100 |
+
},
|
101 |
+
"node_modules/asynckit": {
|
102 |
+
"version": "0.4.0",
|
103 |
+
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
104 |
+
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
105 |
+
"license": "MIT"
|
106 |
+
},
|
107 |
+
"node_modules/axios": {
|
108 |
+
"version": "1.9.0",
|
109 |
+
"resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz",
|
110 |
+
"integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==",
|
111 |
+
"license": "MIT",
|
112 |
+
"dependencies": {
|
113 |
+
"follow-redirects": "^1.15.6",
|
114 |
+
"form-data": "^4.0.0",
|
115 |
+
"proxy-from-env": "^1.1.0"
|
116 |
+
}
|
117 |
+
},
|
118 |
+
"node_modules/balanced-match": {
|
119 |
+
"version": "1.0.2",
|
120 |
+
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
121 |
+
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
122 |
+
"dev": true,
|
123 |
+
"license": "MIT"
|
124 |
+
},
|
125 |
+
"node_modules/binary-extensions": {
|
126 |
+
"version": "2.3.0",
|
127 |
+
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
128 |
+
"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
|
129 |
+
"dev": true,
|
130 |
+
"license": "MIT",
|
131 |
+
"engines": {
|
132 |
+
"node": ">=8"
|
133 |
+
},
|
134 |
+
"funding": {
|
135 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
136 |
+
}
|
137 |
+
},
|
138 |
+
"node_modules/body-parser": {
|
139 |
+
"version": "1.20.3",
|
140 |
+
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
|
141 |
+
"integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
|
142 |
+
"license": "MIT",
|
143 |
+
"dependencies": {
|
144 |
+
"bytes": "3.1.2",
|
145 |
+
"content-type": "~1.0.5",
|
146 |
+
"debug": "2.6.9",
|
147 |
+
"depd": "2.0.0",
|
148 |
+
"destroy": "1.2.0",
|
149 |
+
"http-errors": "2.0.0",
|
150 |
+
"iconv-lite": "0.4.24",
|
151 |
+
"on-finished": "2.4.1",
|
152 |
+
"qs": "6.13.0",
|
153 |
+
"raw-body": "2.5.2",
|
154 |
+
"type-is": "~1.6.18",
|
155 |
+
"unpipe": "1.0.0"
|
156 |
+
},
|
157 |
+
"engines": {
|
158 |
+
"node": ">= 0.8",
|
159 |
+
"npm": "1.2.8000 || >= 1.4.16"
|
160 |
+
}
|
161 |
+
},
|
162 |
+
"node_modules/brace-expansion": {
|
163 |
+
"version": "1.1.11",
|
164 |
+
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
165 |
+
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
166 |
+
"dev": true,
|
167 |
+
"license": "MIT",
|
168 |
+
"dependencies": {
|
169 |
+
"balanced-match": "^1.0.0",
|
170 |
+
"concat-map": "0.0.1"
|
171 |
+
}
|
172 |
+
},
|
173 |
+
"node_modules/braces": {
|
174 |
+
"version": "3.0.3",
|
175 |
+
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
176 |
+
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
177 |
+
"dev": true,
|
178 |
+
"license": "MIT",
|
179 |
+
"dependencies": {
|
180 |
+
"fill-range": "^7.1.1"
|
181 |
+
},
|
182 |
+
"engines": {
|
183 |
+
"node": ">=8"
|
184 |
+
}
|
185 |
+
},
|
186 |
+
"node_modules/bytes": {
|
187 |
+
"version": "3.1.2",
|
188 |
+
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
189 |
+
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
|
190 |
+
"license": "MIT",
|
191 |
+
"engines": {
|
192 |
+
"node": ">= 0.8"
|
193 |
+
}
|
194 |
+
},
|
195 |
+
"node_modules/call-bind-apply-helpers": {
|
196 |
+
"version": "1.0.2",
|
197 |
+
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
198 |
+
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
199 |
+
"license": "MIT",
|
200 |
+
"dependencies": {
|
201 |
+
"es-errors": "^1.3.0",
|
202 |
+
"function-bind": "^1.1.2"
|
203 |
+
},
|
204 |
+
"engines": {
|
205 |
+
"node": ">= 0.4"
|
206 |
+
}
|
207 |
+
},
|
208 |
+
"node_modules/call-bound": {
|
209 |
+
"version": "1.0.4",
|
210 |
+
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
|
211 |
+
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
|
212 |
+
"license": "MIT",
|
213 |
+
"dependencies": {
|
214 |
+
"call-bind-apply-helpers": "^1.0.2",
|
215 |
+
"get-intrinsic": "^1.3.0"
|
216 |
+
},
|
217 |
+
"engines": {
|
218 |
+
"node": ">= 0.4"
|
219 |
+
},
|
220 |
+
"funding": {
|
221 |
+
"url": "https://github.com/sponsors/ljharb"
|
222 |
+
}
|
223 |
+
},
|
224 |
+
"node_modules/chalk": {
|
225 |
+
"version": "4.1.2",
|
226 |
+
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
227 |
+
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
228 |
+
"license": "MIT",
|
229 |
+
"dependencies": {
|
230 |
+
"ansi-styles": "^4.1.0",
|
231 |
+
"supports-color": "^7.1.0"
|
232 |
+
},
|
233 |
+
"engines": {
|
234 |
+
"node": ">=10"
|
235 |
+
},
|
236 |
+
"funding": {
|
237 |
+
"url": "https://github.com/chalk/chalk?sponsor=1"
|
238 |
+
}
|
239 |
+
},
|
240 |
+
"node_modules/chalk/node_modules/has-flag": {
|
241 |
+
"version": "4.0.0",
|
242 |
+
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
243 |
+
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
244 |
+
"license": "MIT",
|
245 |
+
"engines": {
|
246 |
+
"node": ">=8"
|
247 |
+
}
|
248 |
+
},
|
249 |
+
"node_modules/chalk/node_modules/supports-color": {
|
250 |
+
"version": "7.2.0",
|
251 |
+
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
252 |
+
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
253 |
+
"license": "MIT",
|
254 |
+
"dependencies": {
|
255 |
+
"has-flag": "^4.0.0"
|
256 |
+
},
|
257 |
+
"engines": {
|
258 |
+
"node": ">=8"
|
259 |
+
}
|
260 |
+
},
|
261 |
+
"node_modules/chokidar": {
|
262 |
+
"version": "3.6.0",
|
263 |
+
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
|
264 |
+
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
|
265 |
+
"dev": true,
|
266 |
+
"license": "MIT",
|
267 |
+
"dependencies": {
|
268 |
+
"anymatch": "~3.1.2",
|
269 |
+
"braces": "~3.0.2",
|
270 |
+
"glob-parent": "~5.1.2",
|
271 |
+
"is-binary-path": "~2.1.0",
|
272 |
+
"is-glob": "~4.0.1",
|
273 |
+
"normalize-path": "~3.0.0",
|
274 |
+
"readdirp": "~3.6.0"
|
275 |
+
},
|
276 |
+
"engines": {
|
277 |
+
"node": ">= 8.10.0"
|
278 |
+
},
|
279 |
+
"funding": {
|
280 |
+
"url": "https://paulmillr.com/funding/"
|
281 |
+
},
|
282 |
+
"optionalDependencies": {
|
283 |
+
"fsevents": "~2.3.2"
|
284 |
+
}
|
285 |
+
},
|
286 |
+
"node_modules/color-convert": {
|
287 |
+
"version": "2.0.1",
|
288 |
+
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
289 |
+
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
290 |
+
"license": "MIT",
|
291 |
+
"dependencies": {
|
292 |
+
"color-name": "~1.1.4"
|
293 |
+
},
|
294 |
+
"engines": {
|
295 |
+
"node": ">=7.0.0"
|
296 |
+
}
|
297 |
+
},
|
298 |
+
"node_modules/color-name": {
|
299 |
+
"version": "1.1.4",
|
300 |
+
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
301 |
+
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
302 |
+
"license": "MIT"
|
303 |
+
},
|
304 |
+
"node_modules/combined-stream": {
|
305 |
+
"version": "1.0.8",
|
306 |
+
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
307 |
+
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
308 |
+
"license": "MIT",
|
309 |
+
"dependencies": {
|
310 |
+
"delayed-stream": "~1.0.0"
|
311 |
+
},
|
312 |
+
"engines": {
|
313 |
+
"node": ">= 0.8"
|
314 |
+
}
|
315 |
+
},
|
316 |
+
"node_modules/concat-map": {
|
317 |
+
"version": "0.0.1",
|
318 |
+
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
319 |
+
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
320 |
+
"dev": true,
|
321 |
+
"license": "MIT"
|
322 |
+
},
|
323 |
+
"node_modules/content-disposition": {
|
324 |
+
"version": "0.5.4",
|
325 |
+
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
326 |
+
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
327 |
+
"license": "MIT",
|
328 |
+
"dependencies": {
|
329 |
+
"safe-buffer": "5.2.1"
|
330 |
+
},
|
331 |
+
"engines": {
|
332 |
+
"node": ">= 0.6"
|
333 |
+
}
|
334 |
+
},
|
335 |
+
"node_modules/content-type": {
|
336 |
+
"version": "1.0.5",
|
337 |
+
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
338 |
+
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
339 |
+
"license": "MIT",
|
340 |
+
"engines": {
|
341 |
+
"node": ">= 0.6"
|
342 |
+
}
|
343 |
+
},
|
344 |
+
"node_modules/cookie": {
|
345 |
+
"version": "0.7.1",
|
346 |
+
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
|
347 |
+
"integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
|
348 |
+
"license": "MIT",
|
349 |
+
"engines": {
|
350 |
+
"node": ">= 0.6"
|
351 |
+
}
|
352 |
+
},
|
353 |
+
"node_modules/cookie-signature": {
|
354 |
+
"version": "1.0.6",
|
355 |
+
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
356 |
+
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
|
357 |
+
"license": "MIT"
|
358 |
+
},
|
359 |
+
"node_modules/cssstyle": {
|
360 |
+
"version": "3.0.0",
|
361 |
+
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-3.0.0.tgz",
|
362 |
+
"integrity": "sha512-N4u2ABATi3Qplzf0hWbVCdjenim8F3ojEXpBDF5hBpjzW182MjNGLqfmQ0SkSPeQ+V86ZXgeH8aXj6kayd4jgg==",
|
363 |
+
"license": "MIT",
|
364 |
+
"dependencies": {
|
365 |
+
"rrweb-cssom": "^0.6.0"
|
366 |
+
},
|
367 |
+
"engines": {
|
368 |
+
"node": ">=14"
|
369 |
+
}
|
370 |
+
},
|
371 |
+
"node_modules/data-uri-to-buffer": {
|
372 |
+
"version": "4.0.1",
|
373 |
+
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
374 |
+
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
|
375 |
+
"license": "MIT",
|
376 |
+
"engines": {
|
377 |
+
"node": ">= 12"
|
378 |
+
}
|
379 |
+
},
|
380 |
+
"node_modules/data-urls": {
|
381 |
+
"version": "4.0.0",
|
382 |
+
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-4.0.0.tgz",
|
383 |
+
"integrity": "sha512-/mMTei/JXPqvFqQtfyTowxmJVwr2PVAeCcDxyFf6LhoOu/09TX2OX3kb2wzi4DMXcfj4OItwDOnhl5oziPnT6g==",
|
384 |
+
"license": "MIT",
|
385 |
+
"dependencies": {
|
386 |
+
"abab": "^2.0.6",
|
387 |
+
"whatwg-mimetype": "^3.0.0",
|
388 |
+
"whatwg-url": "^12.0.0"
|
389 |
+
},
|
390 |
+
"engines": {
|
391 |
+
"node": ">=14"
|
392 |
+
}
|
393 |
+
},
|
394 |
+
"node_modules/debug": {
|
395 |
+
"version": "2.6.9",
|
396 |
+
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
397 |
+
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
398 |
+
"license": "MIT",
|
399 |
+
"dependencies": {
|
400 |
+
"ms": "2.0.0"
|
401 |
+
}
|
402 |
+
},
|
403 |
+
"node_modules/decimal.js": {
|
404 |
+
"version": "10.5.0",
|
405 |
+
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.5.0.tgz",
|
406 |
+
"integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==",
|
407 |
+
"license": "MIT"
|
408 |
+
},
|
409 |
+
"node_modules/delayed-stream": {
|
410 |
+
"version": "1.0.0",
|
411 |
+
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
412 |
+
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
413 |
+
"license": "MIT",
|
414 |
+
"engines": {
|
415 |
+
"node": ">=0.4.0"
|
416 |
+
}
|
417 |
+
},
|
418 |
+
"node_modules/depd": {
|
419 |
+
"version": "2.0.0",
|
420 |
+
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
421 |
+
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
|
422 |
+
"license": "MIT",
|
423 |
+
"engines": {
|
424 |
+
"node": ">= 0.8"
|
425 |
+
}
|
426 |
+
},
|
427 |
+
"node_modules/destroy": {
|
428 |
+
"version": "1.2.0",
|
429 |
+
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
|
430 |
+
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
|
431 |
+
"license": "MIT",
|
432 |
+
"engines": {
|
433 |
+
"node": ">= 0.8",
|
434 |
+
"npm": "1.2.8000 || >= 1.4.16"
|
435 |
+
}
|
436 |
+
},
|
437 |
+
"node_modules/domexception": {
|
438 |
+
"version": "4.0.0",
|
439 |
+
"resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz",
|
440 |
+
"integrity": "sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==",
|
441 |
+
"deprecated": "Use your platform's native DOMException instead",
|
442 |
+
"license": "MIT",
|
443 |
+
"dependencies": {
|
444 |
+
"webidl-conversions": "^7.0.0"
|
445 |
+
},
|
446 |
+
"engines": {
|
447 |
+
"node": ">=12"
|
448 |
+
}
|
449 |
+
},
|
450 |
+
"node_modules/dotenv": {
|
451 |
+
"version": "16.5.0",
|
452 |
+
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
|
453 |
+
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
|
454 |
+
"license": "BSD-2-Clause",
|
455 |
+
"engines": {
|
456 |
+
"node": ">=12"
|
457 |
+
},
|
458 |
+
"funding": {
|
459 |
+
"url": "https://dotenvx.com"
|
460 |
+
}
|
461 |
+
},
|
462 |
+
"node_modules/dunder-proto": {
|
463 |
+
"version": "1.0.1",
|
464 |
+
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
465 |
+
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
466 |
+
"license": "MIT",
|
467 |
+
"dependencies": {
|
468 |
+
"call-bind-apply-helpers": "^1.0.1",
|
469 |
+
"es-errors": "^1.3.0",
|
470 |
+
"gopd": "^1.2.0"
|
471 |
+
},
|
472 |
+
"engines": {
|
473 |
+
"node": ">= 0.4"
|
474 |
+
}
|
475 |
+
},
|
476 |
+
"node_modules/ee-first": {
|
477 |
+
"version": "1.1.1",
|
478 |
+
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
479 |
+
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
|
480 |
+
"license": "MIT"
|
481 |
+
},
|
482 |
+
"node_modules/encodeurl": {
|
483 |
+
"version": "2.0.0",
|
484 |
+
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
485 |
+
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
486 |
+
"license": "MIT",
|
487 |
+
"engines": {
|
488 |
+
"node": ">= 0.8"
|
489 |
+
}
|
490 |
+
},
|
491 |
+
"node_modules/entities": {
|
492 |
+
"version": "6.0.0",
|
493 |
+
"resolved": "https://registry.npmjs.org/entities/-/entities-6.0.0.tgz",
|
494 |
+
"integrity": "sha512-aKstq2TDOndCn4diEyp9Uq/Flu2i1GlLkc6XIDQSDMuaFE3OPW5OphLCyQ5SpSJZTb4reN+kTcYru5yIfXoRPw==",
|
495 |
+
"license": "BSD-2-Clause",
|
496 |
+
"engines": {
|
497 |
+
"node": ">=0.12"
|
498 |
+
},
|
499 |
+
"funding": {
|
500 |
+
"url": "https://github.com/fb55/entities?sponsor=1"
|
501 |
+
}
|
502 |
+
},
|
503 |
+
"node_modules/es-define-property": {
|
504 |
+
"version": "1.0.1",
|
505 |
+
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
506 |
+
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
507 |
+
"license": "MIT",
|
508 |
+
"engines": {
|
509 |
+
"node": ">= 0.4"
|
510 |
+
}
|
511 |
+
},
|
512 |
+
"node_modules/es-errors": {
|
513 |
+
"version": "1.3.0",
|
514 |
+
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
515 |
+
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
516 |
+
"license": "MIT",
|
517 |
+
"engines": {
|
518 |
+
"node": ">= 0.4"
|
519 |
+
}
|
520 |
+
},
|
521 |
+
"node_modules/es-object-atoms": {
|
522 |
+
"version": "1.1.1",
|
523 |
+
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
524 |
+
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
525 |
+
"license": "MIT",
|
526 |
+
"dependencies": {
|
527 |
+
"es-errors": "^1.3.0"
|
528 |
+
},
|
529 |
+
"engines": {
|
530 |
+
"node": ">= 0.4"
|
531 |
+
}
|
532 |
+
},
|
533 |
+
"node_modules/es-set-tostringtag": {
|
534 |
+
"version": "2.1.0",
|
535 |
+
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
536 |
+
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
537 |
+
"license": "MIT",
|
538 |
+
"dependencies": {
|
539 |
+
"es-errors": "^1.3.0",
|
540 |
+
"get-intrinsic": "^1.2.6",
|
541 |
+
"has-tostringtag": "^1.0.2",
|
542 |
+
"hasown": "^2.0.2"
|
543 |
+
},
|
544 |
+
"engines": {
|
545 |
+
"node": ">= 0.4"
|
546 |
+
}
|
547 |
+
},
|
548 |
+
"node_modules/escape-html": {
|
549 |
+
"version": "1.0.3",
|
550 |
+
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
551 |
+
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
|
552 |
+
"license": "MIT"
|
553 |
+
},
|
554 |
+
"node_modules/etag": {
|
555 |
+
"version": "1.8.1",
|
556 |
+
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
557 |
+
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
|
558 |
+
"license": "MIT",
|
559 |
+
"engines": {
|
560 |
+
"node": ">= 0.6"
|
561 |
+
}
|
562 |
+
},
|
563 |
+
"node_modules/express": {
|
564 |
+
"version": "4.21.2",
|
565 |
+
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
|
566 |
+
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
|
567 |
+
"license": "MIT",
|
568 |
+
"dependencies": {
|
569 |
+
"accepts": "~1.3.8",
|
570 |
+
"array-flatten": "1.1.1",
|
571 |
+
"body-parser": "1.20.3",
|
572 |
+
"content-disposition": "0.5.4",
|
573 |
+
"content-type": "~1.0.4",
|
574 |
+
"cookie": "0.7.1",
|
575 |
+
"cookie-signature": "1.0.6",
|
576 |
+
"debug": "2.6.9",
|
577 |
+
"depd": "2.0.0",
|
578 |
+
"encodeurl": "~2.0.0",
|
579 |
+
"escape-html": "~1.0.3",
|
580 |
+
"etag": "~1.8.1",
|
581 |
+
"finalhandler": "1.3.1",
|
582 |
+
"fresh": "0.5.2",
|
583 |
+
"http-errors": "2.0.0",
|
584 |
+
"merge-descriptors": "1.0.3",
|
585 |
+
"methods": "~1.1.2",
|
586 |
+
"on-finished": "2.4.1",
|
587 |
+
"parseurl": "~1.3.3",
|
588 |
+
"path-to-regexp": "0.1.12",
|
589 |
+
"proxy-addr": "~2.0.7",
|
590 |
+
"qs": "6.13.0",
|
591 |
+
"range-parser": "~1.2.1",
|
592 |
+
"safe-buffer": "5.2.1",
|
593 |
+
"send": "0.19.0",
|
594 |
+
"serve-static": "1.16.2",
|
595 |
+
"setprototypeof": "1.2.0",
|
596 |
+
"statuses": "2.0.1",
|
597 |
+
"type-is": "~1.6.18",
|
598 |
+
"utils-merge": "1.0.1",
|
599 |
+
"vary": "~1.1.2"
|
600 |
+
},
|
601 |
+
"engines": {
|
602 |
+
"node": ">= 0.10.0"
|
603 |
+
},
|
604 |
+
"funding": {
|
605 |
+
"type": "opencollective",
|
606 |
+
"url": "https://opencollective.com/express"
|
607 |
+
}
|
608 |
+
},
|
609 |
+
"node_modules/fetch-blob": {
|
610 |
+
"version": "3.2.0",
|
611 |
+
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
612 |
+
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
613 |
+
"funding": [
|
614 |
+
{
|
615 |
+
"type": "github",
|
616 |
+
"url": "https://github.com/sponsors/jimmywarting"
|
617 |
+
},
|
618 |
+
{
|
619 |
+
"type": "paypal",
|
620 |
+
"url": "https://paypal.me/jimmywarting"
|
621 |
+
}
|
622 |
+
],
|
623 |
+
"license": "MIT",
|
624 |
+
"dependencies": {
|
625 |
+
"node-domexception": "^1.0.0",
|
626 |
+
"web-streams-polyfill": "^3.0.3"
|
627 |
+
},
|
628 |
+
"engines": {
|
629 |
+
"node": "^12.20 || >= 14.13"
|
630 |
+
}
|
631 |
+
},
|
632 |
+
"node_modules/fill-range": {
|
633 |
+
"version": "7.1.1",
|
634 |
+
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
635 |
+
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
636 |
+
"dev": true,
|
637 |
+
"license": "MIT",
|
638 |
+
"dependencies": {
|
639 |
+
"to-regex-range": "^5.0.1"
|
640 |
+
},
|
641 |
+
"engines": {
|
642 |
+
"node": ">=8"
|
643 |
+
}
|
644 |
+
},
|
645 |
+
"node_modules/finalhandler": {
|
646 |
+
"version": "1.3.1",
|
647 |
+
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
|
648 |
+
"integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
|
649 |
+
"license": "MIT",
|
650 |
+
"dependencies": {
|
651 |
+
"debug": "2.6.9",
|
652 |
+
"encodeurl": "~2.0.0",
|
653 |
+
"escape-html": "~1.0.3",
|
654 |
+
"on-finished": "2.4.1",
|
655 |
+
"parseurl": "~1.3.3",
|
656 |
+
"statuses": "2.0.1",
|
657 |
+
"unpipe": "~1.0.0"
|
658 |
+
},
|
659 |
+
"engines": {
|
660 |
+
"node": ">= 0.8"
|
661 |
+
}
|
662 |
+
},
|
663 |
+
"node_modules/follow-redirects": {
|
664 |
+
"version": "1.15.9",
|
665 |
+
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
666 |
+
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
|
667 |
+
"funding": [
|
668 |
+
{
|
669 |
+
"type": "individual",
|
670 |
+
"url": "https://github.com/sponsors/RubenVerborgh"
|
671 |
+
}
|
672 |
+
],
|
673 |
+
"license": "MIT",
|
674 |
+
"engines": {
|
675 |
+
"node": ">=4.0"
|
676 |
+
},
|
677 |
+
"peerDependenciesMeta": {
|
678 |
+
"debug": {
|
679 |
+
"optional": true
|
680 |
+
}
|
681 |
+
}
|
682 |
+
},
|
683 |
+
"node_modules/form-data": {
|
684 |
+
"version": "4.0.2",
|
685 |
+
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz",
|
686 |
+
"integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==",
|
687 |
+
"license": "MIT",
|
688 |
+
"dependencies": {
|
689 |
+
"asynckit": "^0.4.0",
|
690 |
+
"combined-stream": "^1.0.8",
|
691 |
+
"es-set-tostringtag": "^2.1.0",
|
692 |
+
"mime-types": "^2.1.12"
|
693 |
+
},
|
694 |
+
"engines": {
|
695 |
+
"node": ">= 6"
|
696 |
+
}
|
697 |
+
},
|
698 |
+
"node_modules/formdata-polyfill": {
|
699 |
+
"version": "4.0.10",
|
700 |
+
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
701 |
+
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
702 |
+
"license": "MIT",
|
703 |
+
"dependencies": {
|
704 |
+
"fetch-blob": "^3.1.2"
|
705 |
+
},
|
706 |
+
"engines": {
|
707 |
+
"node": ">=12.20.0"
|
708 |
+
}
|
709 |
+
},
|
710 |
+
"node_modules/forwarded": {
|
711 |
+
"version": "0.2.0",
|
712 |
+
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
713 |
+
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
|
714 |
+
"license": "MIT",
|
715 |
+
"engines": {
|
716 |
+
"node": ">= 0.6"
|
717 |
+
}
|
718 |
+
},
|
719 |
+
"node_modules/fresh": {
|
720 |
+
"version": "0.5.2",
|
721 |
+
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
722 |
+
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
|
723 |
+
"license": "MIT",
|
724 |
+
"engines": {
|
725 |
+
"node": ">= 0.6"
|
726 |
+
}
|
727 |
+
},
|
728 |
+
"node_modules/fsevents": {
|
729 |
+
"version": "2.3.3",
|
730 |
+
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
731 |
+
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
732 |
+
"dev": true,
|
733 |
+
"hasInstallScript": true,
|
734 |
+
"license": "MIT",
|
735 |
+
"optional": true,
|
736 |
+
"os": [
|
737 |
+
"darwin"
|
738 |
+
],
|
739 |
+
"engines": {
|
740 |
+
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
741 |
+
}
|
742 |
+
},
|
743 |
+
"node_modules/function-bind": {
|
744 |
+
"version": "1.1.2",
|
745 |
+
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
746 |
+
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
747 |
+
"license": "MIT",
|
748 |
+
"funding": {
|
749 |
+
"url": "https://github.com/sponsors/ljharb"
|
750 |
+
}
|
751 |
+
},
|
752 |
+
"node_modules/get-intrinsic": {
|
753 |
+
"version": "1.3.0",
|
754 |
+
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
755 |
+
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
756 |
+
"license": "MIT",
|
757 |
+
"dependencies": {
|
758 |
+
"call-bind-apply-helpers": "^1.0.2",
|
759 |
+
"es-define-property": "^1.0.1",
|
760 |
+
"es-errors": "^1.3.0",
|
761 |
+
"es-object-atoms": "^1.1.1",
|
762 |
+
"function-bind": "^1.1.2",
|
763 |
+
"get-proto": "^1.0.1",
|
764 |
+
"gopd": "^1.2.0",
|
765 |
+
"has-symbols": "^1.1.0",
|
766 |
+
"hasown": "^2.0.2",
|
767 |
+
"math-intrinsics": "^1.1.0"
|
768 |
+
},
|
769 |
+
"engines": {
|
770 |
+
"node": ">= 0.4"
|
771 |
+
},
|
772 |
+
"funding": {
|
773 |
+
"url": "https://github.com/sponsors/ljharb"
|
774 |
+
}
|
775 |
+
},
|
776 |
+
"node_modules/get-proto": {
|
777 |
+
"version": "1.0.1",
|
778 |
+
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
779 |
+
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
780 |
+
"license": "MIT",
|
781 |
+
"dependencies": {
|
782 |
+
"dunder-proto": "^1.0.1",
|
783 |
+
"es-object-atoms": "^1.0.0"
|
784 |
+
},
|
785 |
+
"engines": {
|
786 |
+
"node": ">= 0.4"
|
787 |
+
}
|
788 |
+
},
|
789 |
+
"node_modules/glob-parent": {
|
790 |
+
"version": "5.1.2",
|
791 |
+
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
792 |
+
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
793 |
+
"dev": true,
|
794 |
+
"license": "ISC",
|
795 |
+
"dependencies": {
|
796 |
+
"is-glob": "^4.0.1"
|
797 |
+
},
|
798 |
+
"engines": {
|
799 |
+
"node": ">= 6"
|
800 |
+
}
|
801 |
+
},
|
802 |
+
"node_modules/gopd": {
|
803 |
+
"version": "1.2.0",
|
804 |
+
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
805 |
+
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
806 |
+
"license": "MIT",
|
807 |
+
"engines": {
|
808 |
+
"node": ">= 0.4"
|
809 |
+
},
|
810 |
+
"funding": {
|
811 |
+
"url": "https://github.com/sponsors/ljharb"
|
812 |
+
}
|
813 |
+
},
|
814 |
+
"node_modules/has-flag": {
|
815 |
+
"version": "3.0.0",
|
816 |
+
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
817 |
+
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
|
818 |
+
"dev": true,
|
819 |
+
"license": "MIT",
|
820 |
+
"engines": {
|
821 |
+
"node": ">=4"
|
822 |
+
}
|
823 |
+
},
|
824 |
+
"node_modules/has-symbols": {
|
825 |
+
"version": "1.1.0",
|
826 |
+
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
827 |
+
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
828 |
+
"license": "MIT",
|
829 |
+
"engines": {
|
830 |
+
"node": ">= 0.4"
|
831 |
+
},
|
832 |
+
"funding": {
|
833 |
+
"url": "https://github.com/sponsors/ljharb"
|
834 |
+
}
|
835 |
+
},
|
836 |
+
"node_modules/has-tostringtag": {
|
837 |
+
"version": "1.0.2",
|
838 |
+
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
839 |
+
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
840 |
+
"license": "MIT",
|
841 |
+
"dependencies": {
|
842 |
+
"has-symbols": "^1.0.3"
|
843 |
+
},
|
844 |
+
"engines": {
|
845 |
+
"node": ">= 0.4"
|
846 |
+
},
|
847 |
+
"funding": {
|
848 |
+
"url": "https://github.com/sponsors/ljharb"
|
849 |
+
}
|
850 |
+
},
|
851 |
+
"node_modules/hasown": {
|
852 |
+
"version": "2.0.2",
|
853 |
+
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
854 |
+
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
855 |
+
"license": "MIT",
|
856 |
+
"dependencies": {
|
857 |
+
"function-bind": "^1.1.2"
|
858 |
+
},
|
859 |
+
"engines": {
|
860 |
+
"node": ">= 0.4"
|
861 |
+
}
|
862 |
+
},
|
863 |
+
"node_modules/html-encoding-sniffer": {
|
864 |
+
"version": "3.0.0",
|
865 |
+
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
|
866 |
+
"integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==",
|
867 |
+
"license": "MIT",
|
868 |
+
"dependencies": {
|
869 |
+
"whatwg-encoding": "^2.0.0"
|
870 |
+
},
|
871 |
+
"engines": {
|
872 |
+
"node": ">=12"
|
873 |
+
}
|
874 |
+
},
|
875 |
+
"node_modules/http-errors": {
|
876 |
+
"version": "2.0.0",
|
877 |
+
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
|
878 |
+
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
|
879 |
+
"license": "MIT",
|
880 |
+
"dependencies": {
|
881 |
+
"depd": "2.0.0",
|
882 |
+
"inherits": "2.0.4",
|
883 |
+
"setprototypeof": "1.2.0",
|
884 |
+
"statuses": "2.0.1",
|
885 |
+
"toidentifier": "1.0.1"
|
886 |
+
},
|
887 |
+
"engines": {
|
888 |
+
"node": ">= 0.8"
|
889 |
+
}
|
890 |
+
},
|
891 |
+
"node_modules/http-proxy-agent": {
|
892 |
+
"version": "5.0.0",
|
893 |
+
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
|
894 |
+
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
|
895 |
+
"license": "MIT",
|
896 |
+
"dependencies": {
|
897 |
+
"@tootallnate/once": "2",
|
898 |
+
"agent-base": "6",
|
899 |
+
"debug": "4"
|
900 |
+
},
|
901 |
+
"engines": {
|
902 |
+
"node": ">= 6"
|
903 |
+
}
|
904 |
+
},
|
905 |
+
"node_modules/http-proxy-agent/node_modules/agent-base": {
|
906 |
+
"version": "6.0.2",
|
907 |
+
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
908 |
+
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
|
909 |
+
"license": "MIT",
|
910 |
+
"dependencies": {
|
911 |
+
"debug": "4"
|
912 |
+
},
|
913 |
+
"engines": {
|
914 |
+
"node": ">= 6.0.0"
|
915 |
+
}
|
916 |
+
},
|
917 |
+
"node_modules/http-proxy-agent/node_modules/debug": {
|
918 |
+
"version": "4.4.1",
|
919 |
+
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
920 |
+
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
|
921 |
+
"license": "MIT",
|
922 |
+
"dependencies": {
|
923 |
+
"ms": "^2.1.3"
|
924 |
+
},
|
925 |
+
"engines": {
|
926 |
+
"node": ">=6.0"
|
927 |
+
},
|
928 |
+
"peerDependenciesMeta": {
|
929 |
+
"supports-color": {
|
930 |
+
"optional": true
|
931 |
+
}
|
932 |
+
}
|
933 |
+
},
|
934 |
+
"node_modules/http-proxy-agent/node_modules/ms": {
|
935 |
+
"version": "2.1.3",
|
936 |
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
937 |
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
938 |
+
"license": "MIT"
|
939 |
+
},
|
940 |
+
"node_modules/https-proxy-agent": {
|
941 |
+
"version": "7.0.6",
|
942 |
+
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
|
943 |
+
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
|
944 |
+
"license": "MIT",
|
945 |
+
"dependencies": {
|
946 |
+
"agent-base": "^7.1.2",
|
947 |
+
"debug": "4"
|
948 |
+
},
|
949 |
+
"engines": {
|
950 |
+
"node": ">= 14"
|
951 |
+
}
|
952 |
+
},
|
953 |
+
"node_modules/https-proxy-agent/node_modules/debug": {
|
954 |
+
"version": "4.4.1",
|
955 |
+
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
956 |
+
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
|
957 |
+
"license": "MIT",
|
958 |
+
"dependencies": {
|
959 |
+
"ms": "^2.1.3"
|
960 |
+
},
|
961 |
+
"engines": {
|
962 |
+
"node": ">=6.0"
|
963 |
+
},
|
964 |
+
"peerDependenciesMeta": {
|
965 |
+
"supports-color": {
|
966 |
+
"optional": true
|
967 |
+
}
|
968 |
+
}
|
969 |
+
},
|
970 |
+
"node_modules/https-proxy-agent/node_modules/ms": {
|
971 |
+
"version": "2.1.3",
|
972 |
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
973 |
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
974 |
+
"license": "MIT"
|
975 |
+
},
|
976 |
+
"node_modules/iconv-lite": {
|
977 |
+
"version": "0.4.24",
|
978 |
+
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
979 |
+
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
980 |
+
"license": "MIT",
|
981 |
+
"dependencies": {
|
982 |
+
"safer-buffer": ">= 2.1.2 < 3"
|
983 |
+
},
|
984 |
+
"engines": {
|
985 |
+
"node": ">=0.10.0"
|
986 |
+
}
|
987 |
+
},
|
988 |
+
"node_modules/ignore-by-default": {
|
989 |
+
"version": "1.0.1",
|
990 |
+
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
|
991 |
+
"integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
|
992 |
+
"dev": true,
|
993 |
+
"license": "ISC"
|
994 |
+
},
|
995 |
+
"node_modules/inherits": {
|
996 |
+
"version": "2.0.4",
|
997 |
+
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
998 |
+
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
999 |
+
"license": "ISC"
|
1000 |
+
},
|
1001 |
+
"node_modules/ipaddr.js": {
|
1002 |
+
"version": "1.9.1",
|
1003 |
+
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
1004 |
+
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
|
1005 |
+
"license": "MIT",
|
1006 |
+
"engines": {
|
1007 |
+
"node": ">= 0.10"
|
1008 |
+
}
|
1009 |
+
},
|
1010 |
+
"node_modules/is-binary-path": {
|
1011 |
+
"version": "2.1.0",
|
1012 |
+
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
1013 |
+
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
|
1014 |
+
"dev": true,
|
1015 |
+
"license": "MIT",
|
1016 |
+
"dependencies": {
|
1017 |
+
"binary-extensions": "^2.0.0"
|
1018 |
+
},
|
1019 |
+
"engines": {
|
1020 |
+
"node": ">=8"
|
1021 |
+
}
|
1022 |
+
},
|
1023 |
+
"node_modules/is-extglob": {
|
1024 |
+
"version": "2.1.1",
|
1025 |
+
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
1026 |
+
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
1027 |
+
"dev": true,
|
1028 |
+
"license": "MIT",
|
1029 |
+
"engines": {
|
1030 |
+
"node": ">=0.10.0"
|
1031 |
+
}
|
1032 |
+
},
|
1033 |
+
"node_modules/is-glob": {
|
1034 |
+
"version": "4.0.3",
|
1035 |
+
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
1036 |
+
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
1037 |
+
"dev": true,
|
1038 |
+
"license": "MIT",
|
1039 |
+
"dependencies": {
|
1040 |
+
"is-extglob": "^2.1.1"
|
1041 |
+
},
|
1042 |
+
"engines": {
|
1043 |
+
"node": ">=0.10.0"
|
1044 |
+
}
|
1045 |
+
},
|
1046 |
+
"node_modules/is-number": {
|
1047 |
+
"version": "7.0.0",
|
1048 |
+
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
1049 |
+
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
1050 |
+
"dev": true,
|
1051 |
+
"license": "MIT",
|
1052 |
+
"engines": {
|
1053 |
+
"node": ">=0.12.0"
|
1054 |
+
}
|
1055 |
+
},
|
1056 |
+
"node_modules/is-potential-custom-element-name": {
|
1057 |
+
"version": "1.0.1",
|
1058 |
+
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
1059 |
+
"integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
|
1060 |
+
"license": "MIT"
|
1061 |
+
},
|
1062 |
+
"node_modules/jsdom": {
|
1063 |
+
"version": "22.1.0",
|
1064 |
+
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.1.0.tgz",
|
1065 |
+
"integrity": "sha512-/9AVW7xNbsBv6GfWho4TTNjEo9fe6Zhf9O7s0Fhhr3u+awPwAJMKwAMXnkk5vBxflqLW9hTHX/0cs+P3gW+cQw==",
|
1066 |
+
"license": "MIT",
|
1067 |
+
"dependencies": {
|
1068 |
+
"abab": "^2.0.6",
|
1069 |
+
"cssstyle": "^3.0.0",
|
1070 |
+
"data-urls": "^4.0.0",
|
1071 |
+
"decimal.js": "^10.4.3",
|
1072 |
+
"domexception": "^4.0.0",
|
1073 |
+
"form-data": "^4.0.0",
|
1074 |
+
"html-encoding-sniffer": "^3.0.0",
|
1075 |
+
"http-proxy-agent": "^5.0.0",
|
1076 |
+
"https-proxy-agent": "^5.0.1",
|
1077 |
+
"is-potential-custom-element-name": "^1.0.1",
|
1078 |
+
"nwsapi": "^2.2.4",
|
1079 |
+
"parse5": "^7.1.2",
|
1080 |
+
"rrweb-cssom": "^0.6.0",
|
1081 |
+
"saxes": "^6.0.0",
|
1082 |
+
"symbol-tree": "^3.2.4",
|
1083 |
+
"tough-cookie": "^4.1.2",
|
1084 |
+
"w3c-xmlserializer": "^4.0.0",
|
1085 |
+
"webidl-conversions": "^7.0.0",
|
1086 |
+
"whatwg-encoding": "^2.0.0",
|
1087 |
+
"whatwg-mimetype": "^3.0.0",
|
1088 |
+
"whatwg-url": "^12.0.1",
|
1089 |
+
"ws": "^8.13.0",
|
1090 |
+
"xml-name-validator": "^4.0.0"
|
1091 |
+
},
|
1092 |
+
"engines": {
|
1093 |
+
"node": ">=16"
|
1094 |
+
},
|
1095 |
+
"peerDependencies": {
|
1096 |
+
"canvas": "^2.5.0"
|
1097 |
+
},
|
1098 |
+
"peerDependenciesMeta": {
|
1099 |
+
"canvas": {
|
1100 |
+
"optional": true
|
1101 |
+
}
|
1102 |
+
}
|
1103 |
+
},
|
1104 |
+
"node_modules/jsdom/node_modules/agent-base": {
|
1105 |
+
"version": "6.0.2",
|
1106 |
+
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
1107 |
+
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
|
1108 |
+
"license": "MIT",
|
1109 |
+
"dependencies": {
|
1110 |
+
"debug": "4"
|
1111 |
+
},
|
1112 |
+
"engines": {
|
1113 |
+
"node": ">= 6.0.0"
|
1114 |
+
}
|
1115 |
+
},
|
1116 |
+
"node_modules/jsdom/node_modules/debug": {
|
1117 |
+
"version": "4.4.1",
|
1118 |
+
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
1119 |
+
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
|
1120 |
+
"license": "MIT",
|
1121 |
+
"dependencies": {
|
1122 |
+
"ms": "^2.1.3"
|
1123 |
+
},
|
1124 |
+
"engines": {
|
1125 |
+
"node": ">=6.0"
|
1126 |
+
},
|
1127 |
+
"peerDependenciesMeta": {
|
1128 |
+
"supports-color": {
|
1129 |
+
"optional": true
|
1130 |
+
}
|
1131 |
+
}
|
1132 |
+
},
|
1133 |
+
"node_modules/jsdom/node_modules/https-proxy-agent": {
|
1134 |
+
"version": "5.0.1",
|
1135 |
+
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
|
1136 |
+
"integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
|
1137 |
+
"license": "MIT",
|
1138 |
+
"dependencies": {
|
1139 |
+
"agent-base": "6",
|
1140 |
+
"debug": "4"
|
1141 |
+
},
|
1142 |
+
"engines": {
|
1143 |
+
"node": ">= 6"
|
1144 |
+
}
|
1145 |
+
},
|
1146 |
+
"node_modules/jsdom/node_modules/ms": {
|
1147 |
+
"version": "2.1.3",
|
1148 |
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
1149 |
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
1150 |
+
"license": "MIT"
|
1151 |
+
},
|
1152 |
+
"node_modules/math-intrinsics": {
|
1153 |
+
"version": "1.1.0",
|
1154 |
+
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
1155 |
+
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
1156 |
+
"license": "MIT",
|
1157 |
+
"engines": {
|
1158 |
+
"node": ">= 0.4"
|
1159 |
+
}
|
1160 |
+
},
|
1161 |
+
"node_modules/media-typer": {
|
1162 |
+
"version": "0.3.0",
|
1163 |
+
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
1164 |
+
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
|
1165 |
+
"license": "MIT",
|
1166 |
+
"engines": {
|
1167 |
+
"node": ">= 0.6"
|
1168 |
+
}
|
1169 |
+
},
|
1170 |
+
"node_modules/merge-descriptors": {
|
1171 |
+
"version": "1.0.3",
|
1172 |
+
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
|
1173 |
+
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
|
1174 |
+
"license": "MIT",
|
1175 |
+
"funding": {
|
1176 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
1177 |
+
}
|
1178 |
+
},
|
1179 |
+
"node_modules/methods": {
|
1180 |
+
"version": "1.1.2",
|
1181 |
+
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
1182 |
+
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
|
1183 |
+
"license": "MIT",
|
1184 |
+
"engines": {
|
1185 |
+
"node": ">= 0.6"
|
1186 |
+
}
|
1187 |
+
},
|
1188 |
+
"node_modules/mime": {
|
1189 |
+
"version": "1.6.0",
|
1190 |
+
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
1191 |
+
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
1192 |
+
"license": "MIT",
|
1193 |
+
"bin": {
|
1194 |
+
"mime": "cli.js"
|
1195 |
+
},
|
1196 |
+
"engines": {
|
1197 |
+
"node": ">=4"
|
1198 |
+
}
|
1199 |
+
},
|
1200 |
+
"node_modules/mime-db": {
|
1201 |
+
"version": "1.52.0",
|
1202 |
+
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
1203 |
+
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
1204 |
+
"license": "MIT",
|
1205 |
+
"engines": {
|
1206 |
+
"node": ">= 0.6"
|
1207 |
+
}
|
1208 |
+
},
|
1209 |
+
"node_modules/mime-types": {
|
1210 |
+
"version": "2.1.35",
|
1211 |
+
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
1212 |
+
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
1213 |
+
"license": "MIT",
|
1214 |
+
"dependencies": {
|
1215 |
+
"mime-db": "1.52.0"
|
1216 |
+
},
|
1217 |
+
"engines": {
|
1218 |
+
"node": ">= 0.6"
|
1219 |
+
}
|
1220 |
+
},
|
1221 |
+
"node_modules/minimatch": {
|
1222 |
+
"version": "3.1.2",
|
1223 |
+
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
1224 |
+
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
1225 |
+
"dev": true,
|
1226 |
+
"license": "ISC",
|
1227 |
+
"dependencies": {
|
1228 |
+
"brace-expansion": "^1.1.7"
|
1229 |
+
},
|
1230 |
+
"engines": {
|
1231 |
+
"node": "*"
|
1232 |
+
}
|
1233 |
+
},
|
1234 |
+
"node_modules/ms": {
|
1235 |
+
"version": "2.0.0",
|
1236 |
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
1237 |
+
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
1238 |
+
"license": "MIT"
|
1239 |
+
},
|
1240 |
+
"node_modules/negotiator": {
|
1241 |
+
"version": "0.6.3",
|
1242 |
+
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
1243 |
+
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
1244 |
+
"license": "MIT",
|
1245 |
+
"engines": {
|
1246 |
+
"node": ">= 0.6"
|
1247 |
+
}
|
1248 |
+
},
|
1249 |
+
"node_modules/node-domexception": {
|
1250 |
+
"version": "1.0.0",
|
1251 |
+
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
1252 |
+
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
|
1253 |
+
"deprecated": "Use your platform's native DOMException instead",
|
1254 |
+
"funding": [
|
1255 |
+
{
|
1256 |
+
"type": "github",
|
1257 |
+
"url": "https://github.com/sponsors/jimmywarting"
|
1258 |
+
},
|
1259 |
+
{
|
1260 |
+
"type": "github",
|
1261 |
+
"url": "https://paypal.me/jimmywarting"
|
1262 |
+
}
|
1263 |
+
],
|
1264 |
+
"license": "MIT",
|
1265 |
+
"engines": {
|
1266 |
+
"node": ">=10.5.0"
|
1267 |
+
}
|
1268 |
+
},
|
1269 |
+
"node_modules/node-fetch": {
|
1270 |
+
"version": "3.3.2",
|
1271 |
+
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
1272 |
+
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
1273 |
+
"license": "MIT",
|
1274 |
+
"dependencies": {
|
1275 |
+
"data-uri-to-buffer": "^4.0.0",
|
1276 |
+
"fetch-blob": "^3.1.4",
|
1277 |
+
"formdata-polyfill": "^4.0.10"
|
1278 |
+
},
|
1279 |
+
"engines": {
|
1280 |
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
1281 |
+
},
|
1282 |
+
"funding": {
|
1283 |
+
"type": "opencollective",
|
1284 |
+
"url": "https://opencollective.com/node-fetch"
|
1285 |
+
}
|
1286 |
+
},
|
1287 |
+
"node_modules/nodemon": {
|
1288 |
+
"version": "3.1.10",
|
1289 |
+
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
|
1290 |
+
"integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==",
|
1291 |
+
"dev": true,
|
1292 |
+
"license": "MIT",
|
1293 |
+
"dependencies": {
|
1294 |
+
"chokidar": "^3.5.2",
|
1295 |
+
"debug": "^4",
|
1296 |
+
"ignore-by-default": "^1.0.1",
|
1297 |
+
"minimatch": "^3.1.2",
|
1298 |
+
"pstree.remy": "^1.1.8",
|
1299 |
+
"semver": "^7.5.3",
|
1300 |
+
"simple-update-notifier": "^2.0.0",
|
1301 |
+
"supports-color": "^5.5.0",
|
1302 |
+
"touch": "^3.1.0",
|
1303 |
+
"undefsafe": "^2.0.5"
|
1304 |
+
},
|
1305 |
+
"bin": {
|
1306 |
+
"nodemon": "bin/nodemon.js"
|
1307 |
+
},
|
1308 |
+
"engines": {
|
1309 |
+
"node": ">=10"
|
1310 |
+
},
|
1311 |
+
"funding": {
|
1312 |
+
"type": "opencollective",
|
1313 |
+
"url": "https://opencollective.com/nodemon"
|
1314 |
+
}
|
1315 |
+
},
|
1316 |
+
"node_modules/nodemon/node_modules/debug": {
|
1317 |
+
"version": "4.4.1",
|
1318 |
+
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
1319 |
+
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
|
1320 |
+
"dev": true,
|
1321 |
+
"license": "MIT",
|
1322 |
+
"dependencies": {
|
1323 |
+
"ms": "^2.1.3"
|
1324 |
+
},
|
1325 |
+
"engines": {
|
1326 |
+
"node": ">=6.0"
|
1327 |
+
},
|
1328 |
+
"peerDependenciesMeta": {
|
1329 |
+
"supports-color": {
|
1330 |
+
"optional": true
|
1331 |
+
}
|
1332 |
+
}
|
1333 |
+
},
|
1334 |
+
"node_modules/nodemon/node_modules/ms": {
|
1335 |
+
"version": "2.1.3",
|
1336 |
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
1337 |
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
1338 |
+
"dev": true,
|
1339 |
+
"license": "MIT"
|
1340 |
+
},
|
1341 |
+
"node_modules/normalize-path": {
|
1342 |
+
"version": "3.0.0",
|
1343 |
+
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
1344 |
+
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
|
1345 |
+
"dev": true,
|
1346 |
+
"license": "MIT",
|
1347 |
+
"engines": {
|
1348 |
+
"node": ">=0.10.0"
|
1349 |
+
}
|
1350 |
+
},
|
1351 |
+
"node_modules/nwsapi": {
|
1352 |
+
"version": "2.2.20",
|
1353 |
+
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.20.tgz",
|
1354 |
+
"integrity": "sha512-/ieB+mDe4MrrKMT8z+mQL8klXydZWGR5Dowt4RAGKbJ3kIGEx3X4ljUo+6V73IXtUPWgfOlU5B9MlGxFO5T+cA==",
|
1355 |
+
"license": "MIT"
|
1356 |
+
},
|
1357 |
+
"node_modules/object-inspect": {
|
1358 |
+
"version": "1.13.4",
|
1359 |
+
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
1360 |
+
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
|
1361 |
+
"license": "MIT",
|
1362 |
+
"engines": {
|
1363 |
+
"node": ">= 0.4"
|
1364 |
+
},
|
1365 |
+
"funding": {
|
1366 |
+
"url": "https://github.com/sponsors/ljharb"
|
1367 |
+
}
|
1368 |
+
},
|
1369 |
+
"node_modules/on-finished": {
|
1370 |
+
"version": "2.4.1",
|
1371 |
+
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
1372 |
+
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
|
1373 |
+
"license": "MIT",
|
1374 |
+
"dependencies": {
|
1375 |
+
"ee-first": "1.1.1"
|
1376 |
+
},
|
1377 |
+
"engines": {
|
1378 |
+
"node": ">= 0.8"
|
1379 |
+
}
|
1380 |
+
},
|
1381 |
+
"node_modules/parse5": {
|
1382 |
+
"version": "7.3.0",
|
1383 |
+
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
|
1384 |
+
"integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==",
|
1385 |
+
"license": "MIT",
|
1386 |
+
"dependencies": {
|
1387 |
+
"entities": "^6.0.0"
|
1388 |
+
},
|
1389 |
+
"funding": {
|
1390 |
+
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
1391 |
+
}
|
1392 |
+
},
|
1393 |
+
"node_modules/parseurl": {
|
1394 |
+
"version": "1.3.3",
|
1395 |
+
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
1396 |
+
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
|
1397 |
+
"license": "MIT",
|
1398 |
+
"engines": {
|
1399 |
+
"node": ">= 0.8"
|
1400 |
+
}
|
1401 |
+
},
|
1402 |
+
"node_modules/path-to-regexp": {
|
1403 |
+
"version": "0.1.12",
|
1404 |
+
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
|
1405 |
+
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
|
1406 |
+
"license": "MIT"
|
1407 |
+
},
|
1408 |
+
"node_modules/picomatch": {
|
1409 |
+
"version": "2.3.1",
|
1410 |
+
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
1411 |
+
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
1412 |
+
"dev": true,
|
1413 |
+
"license": "MIT",
|
1414 |
+
"engines": {
|
1415 |
+
"node": ">=8.6"
|
1416 |
+
},
|
1417 |
+
"funding": {
|
1418 |
+
"url": "https://github.com/sponsors/jonschlinkert"
|
1419 |
+
}
|
1420 |
+
},
|
1421 |
+
"node_modules/playwright": {
|
1422 |
+
"version": "1.52.0",
|
1423 |
+
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.52.0.tgz",
|
1424 |
+
"integrity": "sha512-JAwMNMBlxJ2oD1kce4KPtMkDeKGHQstdpFPcPH3maElAXon/QZeTvtsfXmTMRyO9TslfoYOXkSsvao2nE1ilTw==",
|
1425 |
+
"license": "Apache-2.0",
|
1426 |
+
"dependencies": {
|
1427 |
+
"playwright-core": "1.52.0"
|
1428 |
+
},
|
1429 |
+
"bin": {
|
1430 |
+
"playwright": "cli.js"
|
1431 |
+
},
|
1432 |
+
"engines": {
|
1433 |
+
"node": ">=18"
|
1434 |
+
},
|
1435 |
+
"optionalDependencies": {
|
1436 |
+
"fsevents": "2.3.2"
|
1437 |
+
}
|
1438 |
+
},
|
1439 |
+
"node_modules/playwright-core": {
|
1440 |
+
"version": "1.52.0",
|
1441 |
+
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.52.0.tgz",
|
1442 |
+
"integrity": "sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==",
|
1443 |
+
"license": "Apache-2.0",
|
1444 |
+
"bin": {
|
1445 |
+
"playwright-core": "cli.js"
|
1446 |
+
},
|
1447 |
+
"engines": {
|
1448 |
+
"node": ">=18"
|
1449 |
+
}
|
1450 |
+
},
|
1451 |
+
"node_modules/playwright/node_modules/fsevents": {
|
1452 |
+
"version": "2.3.2",
|
1453 |
+
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
1454 |
+
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
1455 |
+
"hasInstallScript": true,
|
1456 |
+
"license": "MIT",
|
1457 |
+
"optional": true,
|
1458 |
+
"os": [
|
1459 |
+
"darwin"
|
1460 |
+
],
|
1461 |
+
"engines": {
|
1462 |
+
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
1463 |
+
}
|
1464 |
+
},
|
1465 |
+
"node_modules/proxy-addr": {
|
1466 |
+
"version": "2.0.7",
|
1467 |
+
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
1468 |
+
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
|
1469 |
+
"license": "MIT",
|
1470 |
+
"dependencies": {
|
1471 |
+
"forwarded": "0.2.0",
|
1472 |
+
"ipaddr.js": "1.9.1"
|
1473 |
+
},
|
1474 |
+
"engines": {
|
1475 |
+
"node": ">= 0.10"
|
1476 |
+
}
|
1477 |
+
},
|
1478 |
+
"node_modules/proxy-from-env": {
|
1479 |
+
"version": "1.1.0",
|
1480 |
+
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
1481 |
+
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
1482 |
+
"license": "MIT"
|
1483 |
+
},
|
1484 |
+
"node_modules/psl": {
|
1485 |
+
"version": "1.15.0",
|
1486 |
+
"resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz",
|
1487 |
+
"integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==",
|
1488 |
+
"license": "MIT",
|
1489 |
+
"dependencies": {
|
1490 |
+
"punycode": "^2.3.1"
|
1491 |
+
},
|
1492 |
+
"funding": {
|
1493 |
+
"url": "https://github.com/sponsors/lupomontero"
|
1494 |
+
}
|
1495 |
+
},
|
1496 |
+
"node_modules/pstree.remy": {
|
1497 |
+
"version": "1.1.8",
|
1498 |
+
"resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
|
1499 |
+
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
|
1500 |
+
"dev": true,
|
1501 |
+
"license": "MIT"
|
1502 |
+
},
|
1503 |
+
"node_modules/punycode": {
|
1504 |
+
"version": "2.3.1",
|
1505 |
+
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
1506 |
+
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
1507 |
+
"license": "MIT",
|
1508 |
+
"engines": {
|
1509 |
+
"node": ">=6"
|
1510 |
+
}
|
1511 |
+
},
|
1512 |
+
"node_modules/qs": {
|
1513 |
+
"version": "6.13.0",
|
1514 |
+
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
|
1515 |
+
"integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
|
1516 |
+
"license": "BSD-3-Clause",
|
1517 |
+
"dependencies": {
|
1518 |
+
"side-channel": "^1.0.6"
|
1519 |
+
},
|
1520 |
+
"engines": {
|
1521 |
+
"node": ">=0.6"
|
1522 |
+
},
|
1523 |
+
"funding": {
|
1524 |
+
"url": "https://github.com/sponsors/ljharb"
|
1525 |
+
}
|
1526 |
+
},
|
1527 |
+
"node_modules/querystringify": {
|
1528 |
+
"version": "2.2.0",
|
1529 |
+
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
1530 |
+
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
|
1531 |
+
"license": "MIT"
|
1532 |
+
},
|
1533 |
+
"node_modules/range-parser": {
|
1534 |
+
"version": "1.2.1",
|
1535 |
+
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
1536 |
+
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
|
1537 |
+
"license": "MIT",
|
1538 |
+
"engines": {
|
1539 |
+
"node": ">= 0.6"
|
1540 |
+
}
|
1541 |
+
},
|
1542 |
+
"node_modules/raw-body": {
|
1543 |
+
"version": "2.5.2",
|
1544 |
+
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
1545 |
+
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
1546 |
+
"license": "MIT",
|
1547 |
+
"dependencies": {
|
1548 |
+
"bytes": "3.1.2",
|
1549 |
+
"http-errors": "2.0.0",
|
1550 |
+
"iconv-lite": "0.4.24",
|
1551 |
+
"unpipe": "1.0.0"
|
1552 |
+
},
|
1553 |
+
"engines": {
|
1554 |
+
"node": ">= 0.8"
|
1555 |
+
}
|
1556 |
+
},
|
1557 |
+
"node_modules/readdirp": {
|
1558 |
+
"version": "3.6.0",
|
1559 |
+
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
1560 |
+
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
|
1561 |
+
"dev": true,
|
1562 |
+
"license": "MIT",
|
1563 |
+
"dependencies": {
|
1564 |
+
"picomatch": "^2.2.1"
|
1565 |
+
},
|
1566 |
+
"engines": {
|
1567 |
+
"node": ">=8.10.0"
|
1568 |
+
}
|
1569 |
+
},
|
1570 |
+
"node_modules/requires-port": {
|
1571 |
+
"version": "1.0.0",
|
1572 |
+
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
1573 |
+
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
|
1574 |
+
"license": "MIT"
|
1575 |
+
},
|
1576 |
+
"node_modules/rrweb-cssom": {
|
1577 |
+
"version": "0.6.0",
|
1578 |
+
"resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz",
|
1579 |
+
"integrity": "sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw==",
|
1580 |
+
"license": "MIT"
|
1581 |
+
},
|
1582 |
+
"node_modules/safe-buffer": {
|
1583 |
+
"version": "5.2.1",
|
1584 |
+
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
1585 |
+
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
1586 |
+
"funding": [
|
1587 |
+
{
|
1588 |
+
"type": "github",
|
1589 |
+
"url": "https://github.com/sponsors/feross"
|
1590 |
+
},
|
1591 |
+
{
|
1592 |
+
"type": "patreon",
|
1593 |
+
"url": "https://www.patreon.com/feross"
|
1594 |
+
},
|
1595 |
+
{
|
1596 |
+
"type": "consulting",
|
1597 |
+
"url": "https://feross.org/support"
|
1598 |
+
}
|
1599 |
+
],
|
1600 |
+
"license": "MIT"
|
1601 |
+
},
|
1602 |
+
"node_modules/safer-buffer": {
|
1603 |
+
"version": "2.1.2",
|
1604 |
+
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
1605 |
+
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
1606 |
+
"license": "MIT"
|
1607 |
+
},
|
1608 |
+
"node_modules/saxes": {
|
1609 |
+
"version": "6.0.0",
|
1610 |
+
"resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
|
1611 |
+
"integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",
|
1612 |
+
"license": "ISC",
|
1613 |
+
"dependencies": {
|
1614 |
+
"xmlchars": "^2.2.0"
|
1615 |
+
},
|
1616 |
+
"engines": {
|
1617 |
+
"node": ">=v12.22.7"
|
1618 |
+
}
|
1619 |
+
},
|
1620 |
+
"node_modules/semver": {
|
1621 |
+
"version": "7.7.2",
|
1622 |
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
1623 |
+
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
1624 |
+
"dev": true,
|
1625 |
+
"license": "ISC",
|
1626 |
+
"bin": {
|
1627 |
+
"semver": "bin/semver.js"
|
1628 |
+
},
|
1629 |
+
"engines": {
|
1630 |
+
"node": ">=10"
|
1631 |
+
}
|
1632 |
+
},
|
1633 |
+
"node_modules/send": {
|
1634 |
+
"version": "0.19.0",
|
1635 |
+
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
|
1636 |
+
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
|
1637 |
+
"license": "MIT",
|
1638 |
+
"dependencies": {
|
1639 |
+
"debug": "2.6.9",
|
1640 |
+
"depd": "2.0.0",
|
1641 |
+
"destroy": "1.2.0",
|
1642 |
+
"encodeurl": "~1.0.2",
|
1643 |
+
"escape-html": "~1.0.3",
|
1644 |
+
"etag": "~1.8.1",
|
1645 |
+
"fresh": "0.5.2",
|
1646 |
+
"http-errors": "2.0.0",
|
1647 |
+
"mime": "1.6.0",
|
1648 |
+
"ms": "2.1.3",
|
1649 |
+
"on-finished": "2.4.1",
|
1650 |
+
"range-parser": "~1.2.1",
|
1651 |
+
"statuses": "2.0.1"
|
1652 |
+
},
|
1653 |
+
"engines": {
|
1654 |
+
"node": ">= 0.8.0"
|
1655 |
+
}
|
1656 |
+
},
|
1657 |
+
"node_modules/send/node_modules/encodeurl": {
|
1658 |
+
"version": "1.0.2",
|
1659 |
+
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
1660 |
+
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
|
1661 |
+
"license": "MIT",
|
1662 |
+
"engines": {
|
1663 |
+
"node": ">= 0.8"
|
1664 |
+
}
|
1665 |
+
},
|
1666 |
+
"node_modules/send/node_modules/ms": {
|
1667 |
+
"version": "2.1.3",
|
1668 |
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
1669 |
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
1670 |
+
"license": "MIT"
|
1671 |
+
},
|
1672 |
+
"node_modules/serve-static": {
|
1673 |
+
"version": "1.16.2",
|
1674 |
+
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
|
1675 |
+
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
|
1676 |
+
"license": "MIT",
|
1677 |
+
"dependencies": {
|
1678 |
+
"encodeurl": "~2.0.0",
|
1679 |
+
"escape-html": "~1.0.3",
|
1680 |
+
"parseurl": "~1.3.3",
|
1681 |
+
"send": "0.19.0"
|
1682 |
+
},
|
1683 |
+
"engines": {
|
1684 |
+
"node": ">= 0.8.0"
|
1685 |
+
}
|
1686 |
+
},
|
1687 |
+
"node_modules/setprototypeof": {
|
1688 |
+
"version": "1.2.0",
|
1689 |
+
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
1690 |
+
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
1691 |
+
"license": "ISC"
|
1692 |
+
},
|
1693 |
+
"node_modules/side-channel": {
|
1694 |
+
"version": "1.1.0",
|
1695 |
+
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
|
1696 |
+
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
|
1697 |
+
"license": "MIT",
|
1698 |
+
"dependencies": {
|
1699 |
+
"es-errors": "^1.3.0",
|
1700 |
+
"object-inspect": "^1.13.3",
|
1701 |
+
"side-channel-list": "^1.0.0",
|
1702 |
+
"side-channel-map": "^1.0.1",
|
1703 |
+
"side-channel-weakmap": "^1.0.2"
|
1704 |
+
},
|
1705 |
+
"engines": {
|
1706 |
+
"node": ">= 0.4"
|
1707 |
+
},
|
1708 |
+
"funding": {
|
1709 |
+
"url": "https://github.com/sponsors/ljharb"
|
1710 |
+
}
|
1711 |
+
},
|
1712 |
+
"node_modules/side-channel-list": {
|
1713 |
+
"version": "1.0.0",
|
1714 |
+
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
|
1715 |
+
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
|
1716 |
+
"license": "MIT",
|
1717 |
+
"dependencies": {
|
1718 |
+
"es-errors": "^1.3.0",
|
1719 |
+
"object-inspect": "^1.13.3"
|
1720 |
+
},
|
1721 |
+
"engines": {
|
1722 |
+
"node": ">= 0.4"
|
1723 |
+
},
|
1724 |
+
"funding": {
|
1725 |
+
"url": "https://github.com/sponsors/ljharb"
|
1726 |
+
}
|
1727 |
+
},
|
1728 |
+
"node_modules/side-channel-map": {
|
1729 |
+
"version": "1.0.1",
|
1730 |
+
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
|
1731 |
+
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
|
1732 |
+
"license": "MIT",
|
1733 |
+
"dependencies": {
|
1734 |
+
"call-bound": "^1.0.2",
|
1735 |
+
"es-errors": "^1.3.0",
|
1736 |
+
"get-intrinsic": "^1.2.5",
|
1737 |
+
"object-inspect": "^1.13.3"
|
1738 |
+
},
|
1739 |
+
"engines": {
|
1740 |
+
"node": ">= 0.4"
|
1741 |
+
},
|
1742 |
+
"funding": {
|
1743 |
+
"url": "https://github.com/sponsors/ljharb"
|
1744 |
+
}
|
1745 |
+
},
|
1746 |
+
"node_modules/side-channel-weakmap": {
|
1747 |
+
"version": "1.0.2",
|
1748 |
+
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
|
1749 |
+
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
|
1750 |
+
"license": "MIT",
|
1751 |
+
"dependencies": {
|
1752 |
+
"call-bound": "^1.0.2",
|
1753 |
+
"es-errors": "^1.3.0",
|
1754 |
+
"get-intrinsic": "^1.2.5",
|
1755 |
+
"object-inspect": "^1.13.3",
|
1756 |
+
"side-channel-map": "^1.0.1"
|
1757 |
+
},
|
1758 |
+
"engines": {
|
1759 |
+
"node": ">= 0.4"
|
1760 |
+
},
|
1761 |
+
"funding": {
|
1762 |
+
"url": "https://github.com/sponsors/ljharb"
|
1763 |
+
}
|
1764 |
+
},
|
1765 |
+
"node_modules/simple-update-notifier": {
|
1766 |
+
"version": "2.0.0",
|
1767 |
+
"resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
|
1768 |
+
"integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
|
1769 |
+
"dev": true,
|
1770 |
+
"license": "MIT",
|
1771 |
+
"dependencies": {
|
1772 |
+
"semver": "^7.5.3"
|
1773 |
+
},
|
1774 |
+
"engines": {
|
1775 |
+
"node": ">=10"
|
1776 |
+
}
|
1777 |
+
},
|
1778 |
+
"node_modules/statuses": {
|
1779 |
+
"version": "2.0.1",
|
1780 |
+
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
1781 |
+
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
|
1782 |
+
"license": "MIT",
|
1783 |
+
"engines": {
|
1784 |
+
"node": ">= 0.8"
|
1785 |
+
}
|
1786 |
+
},
|
1787 |
+
"node_modules/supports-color": {
|
1788 |
+
"version": "5.5.0",
|
1789 |
+
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
1790 |
+
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
1791 |
+
"dev": true,
|
1792 |
+
"license": "MIT",
|
1793 |
+
"dependencies": {
|
1794 |
+
"has-flag": "^3.0.0"
|
1795 |
+
},
|
1796 |
+
"engines": {
|
1797 |
+
"node": ">=4"
|
1798 |
+
}
|
1799 |
+
},
|
1800 |
+
"node_modules/symbol-tree": {
|
1801 |
+
"version": "3.2.4",
|
1802 |
+
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
1803 |
+
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
1804 |
+
"license": "MIT"
|
1805 |
+
},
|
1806 |
+
"node_modules/to-regex-range": {
|
1807 |
+
"version": "5.0.1",
|
1808 |
+
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
1809 |
+
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
1810 |
+
"dev": true,
|
1811 |
+
"license": "MIT",
|
1812 |
+
"dependencies": {
|
1813 |
+
"is-number": "^7.0.0"
|
1814 |
+
},
|
1815 |
+
"engines": {
|
1816 |
+
"node": ">=8.0"
|
1817 |
+
}
|
1818 |
+
},
|
1819 |
+
"node_modules/toidentifier": {
|
1820 |
+
"version": "1.0.1",
|
1821 |
+
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
1822 |
+
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
|
1823 |
+
"license": "MIT",
|
1824 |
+
"engines": {
|
1825 |
+
"node": ">=0.6"
|
1826 |
+
}
|
1827 |
+
},
|
1828 |
+
"node_modules/touch": {
|
1829 |
+
"version": "3.1.1",
|
1830 |
+
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz",
|
1831 |
+
"integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
|
1832 |
+
"dev": true,
|
1833 |
+
"license": "ISC",
|
1834 |
+
"bin": {
|
1835 |
+
"nodetouch": "bin/nodetouch.js"
|
1836 |
+
}
|
1837 |
+
},
|
1838 |
+
"node_modules/tough-cookie": {
|
1839 |
+
"version": "4.1.4",
|
1840 |
+
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz",
|
1841 |
+
"integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==",
|
1842 |
+
"license": "BSD-3-Clause",
|
1843 |
+
"dependencies": {
|
1844 |
+
"psl": "^1.1.33",
|
1845 |
+
"punycode": "^2.1.1",
|
1846 |
+
"universalify": "^0.2.0",
|
1847 |
+
"url-parse": "^1.5.3"
|
1848 |
+
},
|
1849 |
+
"engines": {
|
1850 |
+
"node": ">=6"
|
1851 |
+
}
|
1852 |
+
},
|
1853 |
+
"node_modules/tr46": {
|
1854 |
+
"version": "4.1.1",
|
1855 |
+
"resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz",
|
1856 |
+
"integrity": "sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==",
|
1857 |
+
"license": "MIT",
|
1858 |
+
"dependencies": {
|
1859 |
+
"punycode": "^2.3.0"
|
1860 |
+
},
|
1861 |
+
"engines": {
|
1862 |
+
"node": ">=14"
|
1863 |
+
}
|
1864 |
+
},
|
1865 |
+
"node_modules/type-is": {
|
1866 |
+
"version": "1.6.18",
|
1867 |
+
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
1868 |
+
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
|
1869 |
+
"license": "MIT",
|
1870 |
+
"dependencies": {
|
1871 |
+
"media-typer": "0.3.0",
|
1872 |
+
"mime-types": "~2.1.24"
|
1873 |
+
},
|
1874 |
+
"engines": {
|
1875 |
+
"node": ">= 0.6"
|
1876 |
+
}
|
1877 |
+
},
|
1878 |
+
"node_modules/undefsafe": {
|
1879 |
+
"version": "2.0.5",
|
1880 |
+
"resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
|
1881 |
+
"integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
|
1882 |
+
"dev": true,
|
1883 |
+
"license": "MIT"
|
1884 |
+
},
|
1885 |
+
"node_modules/universalify": {
|
1886 |
+
"version": "0.2.0",
|
1887 |
+
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
|
1888 |
+
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
|
1889 |
+
"license": "MIT",
|
1890 |
+
"engines": {
|
1891 |
+
"node": ">= 4.0.0"
|
1892 |
+
}
|
1893 |
+
},
|
1894 |
+
"node_modules/unpipe": {
|
1895 |
+
"version": "1.0.0",
|
1896 |
+
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
1897 |
+
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
|
1898 |
+
"license": "MIT",
|
1899 |
+
"engines": {
|
1900 |
+
"node": ">= 0.8"
|
1901 |
+
}
|
1902 |
+
},
|
1903 |
+
"node_modules/url-parse": {
|
1904 |
+
"version": "1.5.10",
|
1905 |
+
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
|
1906 |
+
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
|
1907 |
+
"license": "MIT",
|
1908 |
+
"dependencies": {
|
1909 |
+
"querystringify": "^2.1.1",
|
1910 |
+
"requires-port": "^1.0.0"
|
1911 |
+
}
|
1912 |
+
},
|
1913 |
+
"node_modules/utils-merge": {
|
1914 |
+
"version": "1.0.1",
|
1915 |
+
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
1916 |
+
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
1917 |
+
"license": "MIT",
|
1918 |
+
"engines": {
|
1919 |
+
"node": ">= 0.4.0"
|
1920 |
+
}
|
1921 |
+
},
|
1922 |
+
"node_modules/vary": {
|
1923 |
+
"version": "1.1.2",
|
1924 |
+
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
1925 |
+
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
|
1926 |
+
"license": "MIT",
|
1927 |
+
"engines": {
|
1928 |
+
"node": ">= 0.8"
|
1929 |
+
}
|
1930 |
+
},
|
1931 |
+
"node_modules/w3c-xmlserializer": {
|
1932 |
+
"version": "4.0.0",
|
1933 |
+
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz",
|
1934 |
+
"integrity": "sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==",
|
1935 |
+
"license": "MIT",
|
1936 |
+
"dependencies": {
|
1937 |
+
"xml-name-validator": "^4.0.0"
|
1938 |
+
},
|
1939 |
+
"engines": {
|
1940 |
+
"node": ">=14"
|
1941 |
+
}
|
1942 |
+
},
|
1943 |
+
"node_modules/web-streams-polyfill": {
|
1944 |
+
"version": "3.3.3",
|
1945 |
+
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
|
1946 |
+
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
|
1947 |
+
"license": "MIT",
|
1948 |
+
"engines": {
|
1949 |
+
"node": ">= 8"
|
1950 |
+
}
|
1951 |
+
},
|
1952 |
+
"node_modules/webidl-conversions": {
|
1953 |
+
"version": "7.0.0",
|
1954 |
+
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
1955 |
+
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
|
1956 |
+
"license": "BSD-2-Clause",
|
1957 |
+
"engines": {
|
1958 |
+
"node": ">=12"
|
1959 |
+
}
|
1960 |
+
},
|
1961 |
+
"node_modules/whatwg-encoding": {
|
1962 |
+
"version": "2.0.0",
|
1963 |
+
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",
|
1964 |
+
"integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",
|
1965 |
+
"license": "MIT",
|
1966 |
+
"dependencies": {
|
1967 |
+
"iconv-lite": "0.6.3"
|
1968 |
+
},
|
1969 |
+
"engines": {
|
1970 |
+
"node": ">=12"
|
1971 |
+
}
|
1972 |
+
},
|
1973 |
+
"node_modules/whatwg-encoding/node_modules/iconv-lite": {
|
1974 |
+
"version": "0.6.3",
|
1975 |
+
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
1976 |
+
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
1977 |
+
"license": "MIT",
|
1978 |
+
"dependencies": {
|
1979 |
+
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
1980 |
+
},
|
1981 |
+
"engines": {
|
1982 |
+
"node": ">=0.10.0"
|
1983 |
+
}
|
1984 |
+
},
|
1985 |
+
"node_modules/whatwg-mimetype": {
|
1986 |
+
"version": "3.0.0",
|
1987 |
+
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",
|
1988 |
+
"integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==",
|
1989 |
+
"license": "MIT",
|
1990 |
+
"engines": {
|
1991 |
+
"node": ">=12"
|
1992 |
+
}
|
1993 |
+
},
|
1994 |
+
"node_modules/whatwg-url": {
|
1995 |
+
"version": "12.0.1",
|
1996 |
+
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-12.0.1.tgz",
|
1997 |
+
"integrity": "sha512-Ed/LrqB8EPlGxjS+TrsXcpUond1mhccS3pchLhzSgPCnTimUCKj3IZE75pAs5m6heB2U2TMerKFUXheyHY+VDQ==",
|
1998 |
+
"license": "MIT",
|
1999 |
+
"dependencies": {
|
2000 |
+
"tr46": "^4.1.1",
|
2001 |
+
"webidl-conversions": "^7.0.0"
|
2002 |
+
},
|
2003 |
+
"engines": {
|
2004 |
+
"node": ">=14"
|
2005 |
+
}
|
2006 |
+
},
|
2007 |
+
"node_modules/ws": {
|
2008 |
+
"version": "8.18.2",
|
2009 |
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.2.tgz",
|
2010 |
+
"integrity": "sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ==",
|
2011 |
+
"license": "MIT",
|
2012 |
+
"engines": {
|
2013 |
+
"node": ">=10.0.0"
|
2014 |
+
},
|
2015 |
+
"peerDependencies": {
|
2016 |
+
"bufferutil": "^4.0.1",
|
2017 |
+
"utf-8-validate": ">=5.0.2"
|
2018 |
+
},
|
2019 |
+
"peerDependenciesMeta": {
|
2020 |
+
"bufferutil": {
|
2021 |
+
"optional": true
|
2022 |
+
},
|
2023 |
+
"utf-8-validate": {
|
2024 |
+
"optional": true
|
2025 |
+
}
|
2026 |
+
}
|
2027 |
+
},
|
2028 |
+
"node_modules/xml-name-validator": {
|
2029 |
+
"version": "4.0.0",
|
2030 |
+
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",
|
2031 |
+
"integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==",
|
2032 |
+
"license": "Apache-2.0",
|
2033 |
+
"engines": {
|
2034 |
+
"node": ">=12"
|
2035 |
+
}
|
2036 |
+
},
|
2037 |
+
"node_modules/xmlchars": {
|
2038 |
+
"version": "2.2.0",
|
2039 |
+
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
|
2040 |
+
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
2041 |
+
"license": "MIT"
|
2042 |
+
}
|
2043 |
+
}
|
2044 |
+
}
|
package.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "notion2api-nodejs",
|
3 |
+
"version": "1.0.0",
|
4 |
+
"description": "Notion API client with lightweight browser-free option",
|
5 |
+
"main": "src/lightweight-client-express.js",
|
6 |
+
"type": "module",
|
7 |
+
"bin": {
|
8 |
+
"notion-cookie": "src/cookie-cli.js"
|
9 |
+
},
|
10 |
+
"scripts": {
|
11 |
+
"start": "node src/lightweight-client-express.js",
|
12 |
+
"dev": "nodemon src/lightweight-client-express.js",
|
13 |
+
"original": "node src/index.js",
|
14 |
+
"cookie": "node src/cookie-cli.js"
|
15 |
+
},
|
16 |
+
"keywords": [
|
17 |
+
"notion",
|
18 |
+
"openai",
|
19 |
+
"api",
|
20 |
+
"bridge"
|
21 |
+
],
|
22 |
+
"author": "",
|
23 |
+
"license": "MIT",
|
24 |
+
"dependencies": {
|
25 |
+
"axios": "^1.9.0",
|
26 |
+
"chalk": "^4.1.2",
|
27 |
+
"dotenv": "^16.3.1",
|
28 |
+
"express": "^4.18.2",
|
29 |
+
"https-proxy-agent": "^7.0.2",
|
30 |
+
"jsdom": "^22.1.0",
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { JSDOM } from 'jsdom';
|
2 |
+
import fetch from 'node-fetch';
|
3 |
+
import fs from 'fs';
|
4 |
+
import path from 'path';
|
5 |
+
import { fileURLToPath } from 'url';
|
6 |
+
import { dirname } from 'path';
|
7 |
+
|
8 |
+
// 获取当前文件的目录路径
|
9 |
+
const __filename = fileURLToPath(import.meta.url);
|
10 |
+
const __dirname = dirname(__filename);
|
11 |
+
|
12 |
+
// 日志配置
|
13 |
+
const logger = {
|
14 |
+
info: (message) => console.log(`\x1b[34m[info] ${message}\x1b[0m`),
|
15 |
+
error: (message) => console.error(`\x1b[31m[error] ${message}\x1b[0m`),
|
16 |
+
warning: (message) => console.warn(`\x1b[33m[warn] ${message}\x1b[0m`),
|
17 |
+
success: (message) => console.log(`\x1b[32m[success] ${message}\x1b[0m`),
|
18 |
+
};
|
19 |
+
|
20 |
+
class CookieManager {
|
21 |
+
constructor() {
|
22 |
+
this.cookieEntries = []; // 存储cookie及其对应的ID
|
23 |
+
this.currentIndex = 0;
|
24 |
+
this.initialized = false;
|
25 |
+
this.maxRetries = 3; // 最大重试次数
|
26 |
+
this.proxyUrl = process.env.PROXY_URL || "";
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* 从文件加载cookie
|
31 |
+
* @param {string} filePath - cookie文件路径
|
32 |
+
* @returns {Promise<boolean>} - 是否加载成功
|
33 |
+
*/
|
34 |
+
async loadFromFile(filePath) {
|
35 |
+
try {
|
36 |
+
// 确保文件路径是绝对路径
|
37 |
+
const absolutePath = path.isAbsolute(filePath)
|
38 |
+
? filePath
|
39 |
+
: path.join(dirname(__dirname), filePath);
|
40 |
+
|
41 |
+
logger.info(`从文件加载cookie: ${absolutePath}`);
|
42 |
+
|
43 |
+
// 检查文件是否存在
|
44 |
+
if (!fs.existsSync(absolutePath)) {
|
45 |
+
logger.error(`Cookie文件不存在: ${absolutePath}`);
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
|
49 |
+
// 读取文件内容
|
50 |
+
const fileContent = fs.readFileSync(absolutePath, 'utf8');
|
51 |
+
|
52 |
+
// 根据文件扩展名处理不同格式
|
53 |
+
const ext = path.extname(absolutePath).toLowerCase();
|
54 |
+
let cookieArray = [];
|
55 |
+
|
56 |
+
if (ext === '.json') {
|
57 |
+
// JSON格式
|
58 |
+
try {
|
59 |
+
const jsonData = JSON.parse(fileContent);
|
60 |
+
if (Array.isArray(jsonData)) {
|
61 |
+
cookieArray = jsonData;
|
62 |
+
} else if (jsonData.cookies && Array.isArray(jsonData.cookies)) {
|
63 |
+
cookieArray = jsonData.cookies;
|
64 |
+
} else {
|
65 |
+
logger.error('JSON文件格式错误,应为cookie数组或包含cookies数组的对象');
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
} catch (error) {
|
69 |
+
logger.error(`解析JSON文件失败: ${error.message}`);
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
} else {
|
73 |
+
// 文本格式,每行一个cookie
|
74 |
+
cookieArray = fileContent
|
75 |
+
.split('\n')
|
76 |
+
.map(line => line.trim())
|
77 |
+
.filter(line => line && !line.startsWith('#'));
|
78 |
+
}
|
79 |
+
|
80 |
+
logger.info(`从文件中读取了 ${cookieArray.length} 个cookie`);
|
81 |
+
|
82 |
+
// 初始化cookie
|
83 |
+
return await this.initialize(cookieArray.join('|'));
|
84 |
+
|
85 |
+
} catch (error) {
|
86 |
+
logger.error(`从文件加载cookie失败: ${error.message}`);
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* 初始化cookie管理器
|
93 |
+
* @param {string} cookiesString - 以"|"分隔的cookie字符串
|
94 |
+
* @returns {Promise<boolean>} - 是否初始化成功
|
95 |
+
*/
|
96 |
+
async initialize(cookiesString) {
|
97 |
+
if (!cookiesString) {
|
98 |
+
logger.error('未提供cookie字符串');
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
+
// 分割cookie字符串
|
103 |
+
const cookieArray = cookiesString.split('|').map(c => c.trim()).filter(c => c);
|
104 |
+
|
105 |
+
if (cookieArray.length === 0) {
|
106 |
+
logger.error('没有有效的cookie');
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
|
110 |
+
logger.info(`发现 ${cookieArray.length} 个cookie,开始获取对应的ID信息...`);
|
111 |
+
|
112 |
+
// 清空现有条目
|
113 |
+
this.cookieEntries = [];
|
114 |
+
|
115 |
+
// 为每个cookie获取ID
|
116 |
+
for (let i = 0; i < cookieArray.length; i++) {
|
117 |
+
const cookie = cookieArray[i];
|
118 |
+
logger.info(`正在处理第 ${i+1}/${cookieArray.length} 个cookie...`);
|
119 |
+
|
120 |
+
const result = await this.fetchNotionIds(cookie);
|
121 |
+
if (result.success) {
|
122 |
+
this.cookieEntries.push({
|
123 |
+
cookie,
|
124 |
+
spaceId: result.spaceId,
|
125 |
+
userId: result.userId,
|
126 |
+
valid: true,
|
127 |
+
lastUsed: 0 // 记录上次使用时间戳
|
128 |
+
});
|
129 |
+
logger.success(`第 ${i+1} 个cookie验证成功`);
|
130 |
+
} else {
|
131 |
+
if (result.status === 401) {
|
132 |
+
logger.error(`第 ${i+1} 个cookie无效(401未授权),已跳过`);
|
133 |
+
} else {
|
134 |
+
logger.warning(`第 ${i+1} 个cookie验证失败: ${result.error},已跳过`);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
// 检查是否有有效的cookie
|
140 |
+
if (this.cookieEntries.length === 0) {
|
141 |
+
logger.error('没有有效的cookie,初始化失败');
|
142 |
+
return false;
|
143 |
+
}
|
144 |
+
|
145 |
+
logger.success(`成功初始化 ${this.cookieEntries.length}/${cookieArray.length} 个cookie`);
|
146 |
+
this.initialized = true;
|
147 |
+
this.currentIndex = 0;
|
148 |
+
return true;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* 保存cookie到文件
|
153 |
+
* @param {string} filePath - 保存路径
|
154 |
+
* @param {boolean} onlyValid - 是否只保存有效的cookie
|
155 |
+
* @returns {boolean} - 是否保存成功
|
156 |
+
*/
|
157 |
+
saveToFile(filePath, onlyValid = true) {
|
158 |
+
try {
|
159 |
+
// 确保文件路径是绝对路径
|
160 |
+
const absolutePath = path.isAbsolute(filePath)
|
161 |
+
? filePath
|
162 |
+
: path.join(dirname(__dirname), filePath);
|
163 |
+
|
164 |
+
// 获取要保存的cookie
|
165 |
+
const cookiesToSave = onlyValid
|
166 |
+
? this.cookieEntries.filter(entry => entry.valid).map(entry => entry.cookie)
|
167 |
+
: this.cookieEntries.map(entry => entry.cookie);
|
168 |
+
|
169 |
+
// 根据文件扩展名选择保存格式
|
170 |
+
const ext = path.extname(absolutePath).toLowerCase();
|
171 |
+
|
172 |
+
if (ext === '.json') {
|
173 |
+
// 保存为JSON格式
|
174 |
+
const jsonData = {
|
175 |
+
cookies: cookiesToSave,
|
176 |
+
updatedAt: new Date().toISOString(),
|
177 |
+
count: cookiesToSave.length
|
178 |
+
};
|
179 |
+
fs.writeFileSync(absolutePath, JSON.stringify(jsonData, null, 2), 'utf8');
|
180 |
+
} else {
|
181 |
+
// 保存为文本格式,每行一个cookie
|
182 |
+
const content = cookiesToSave.join('\n');
|
183 |
+
fs.writeFileSync(absolutePath, content, 'utf8');
|
184 |
+
}
|
185 |
+
|
186 |
+
logger.success(`已将 ${cookiesToSave.length} 个cookie保存到文件: ${absolutePath}`);
|
187 |
+
return true;
|
188 |
+
} catch (error) {
|
189 |
+
logger.error(`保存cookie到文件失败: ${error.message}`);
|
190 |
+
return false;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* 获取Notion的空间ID和用户ID
|
196 |
+
* @param {string} cookie - Notion cookie
|
197 |
+
* @returns {Promise<Object>} - 包含ID信息的对象
|
198 |
+
*/
|
199 |
+
async fetchNotionIds(cookie, retryCount = 0) {
|
200 |
+
if (!cookie) {
|
201 |
+
return { success: false, error: '未提供cookie' };
|
202 |
+
}
|
203 |
+
|
204 |
+
try {
|
205 |
+
// 创建JSDOM实例模拟浏览器环境
|
206 |
+
const dom = new JSDOM("", {
|
207 |
+
url: "https://www.notion.so",
|
208 |
+
referrer: "https://www.notion.so/",
|
209 |
+
contentType: "text/html",
|
210 |
+
includeNodeLocations: true,
|
211 |
+
storageQuota: 10000000,
|
212 |
+
pretendToBeVisual: true,
|
213 |
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"
|
214 |
+
});
|
215 |
+
|
216 |
+
// 设置全局对象
|
217 |
+
const { window } = dom;
|
218 |
+
|
219 |
+
// 安全地设置全局对象
|
220 |
+
if (!global.window) global.window = window;
|
221 |
+
if (!global.document) global.document = window.document;
|
222 |
+
|
223 |
+
// 设置navigator
|
224 |
+
if (!global.navigator) {
|
225 |
+
try {
|
226 |
+
Object.defineProperty(global, 'navigator', {
|
227 |
+
value: window.navigator,
|
228 |
+
writable: true,
|
229 |
+
configurable: true
|
230 |
+
});
|
231 |
+
} catch (navError) {
|
232 |
+
logger.warning(`无法设置navigator: ${navError.message},继续执行`);
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
// 设置cookie
|
237 |
+
document.cookie = cookie;
|
238 |
+
|
239 |
+
// 创建fetch选项
|
240 |
+
const fetchOptions = {
|
241 |
+
method: 'POST',
|
242 |
+
headers: {
|
243 |
+
'Content-Type': 'application/json',
|
244 |
+
'accept': '*/*',
|
245 |
+
'accept-language': 'en-US,en;q=0.9',
|
246 |
+
'notion-audit-log-platform': 'web',
|
247 |
+
'notion-client-version': '23.13.0.3686',
|
248 |
+
'origin': 'https://www.notion.so',
|
249 |
+
'referer': 'https://www.notion.so/',
|
250 |
+
'user-agent': window.navigator.userAgent,
|
251 |
+
'Cookie': cookie
|
252 |
+
},
|
253 |
+
body: JSON.stringify({}),
|
254 |
+
};
|
255 |
+
|
256 |
+
// 添加代理配置(如果有)
|
257 |
+
if (this.proxyUrl) {
|
258 |
+
const { HttpsProxyAgent } = await import('https-proxy-agent');
|
259 |
+
fetchOptions.agent = new HttpsProxyAgent(this.proxyUrl);
|
260 |
+
logger.info(`使用代理: ${this.proxyUrl}`);
|
261 |
+
}
|
262 |
+
|
263 |
+
// 发送请求
|
264 |
+
const response = await fetch("https://www.notion.so/api/v3/getSpaces", fetchOptions);
|
265 |
+
|
266 |
+
// 检查响应状态
|
267 |
+
if (response.status === 401) {
|
268 |
+
return { success: false, status: 401, error: '未授权,cookie无效' };
|
269 |
+
}
|
270 |
+
|
271 |
+
if (!response.ok) {
|
272 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
273 |
+
}
|
274 |
+
|
275 |
+
const data = await response.json();
|
276 |
+
|
277 |
+
// 提取用户ID
|
278 |
+
const userIdKey = Object.keys(data)[0];
|
279 |
+
if (!userIdKey) {
|
280 |
+
throw new Error('无法从响应中提取用户ID');
|
281 |
+
}
|
282 |
+
|
283 |
+
const userId = userIdKey;
|
284 |
+
|
285 |
+
// 提取空间ID
|
286 |
+
const userRoot = data[userIdKey]?.user_root?.[userIdKey];
|
287 |
+
const spaceViewPointers = userRoot?.value?.value?.space_view_pointers;
|
288 |
+
|
289 |
+
if (!spaceViewPointers || !Array.isArray(spaceViewPointers) || spaceViewPointers.length === 0) {
|
290 |
+
throw new Error('在响应中找不到space_view_pointers或spaceId');
|
291 |
+
}
|
292 |
+
|
293 |
+
const spaceId = spaceViewPointers[0].spaceId;
|
294 |
+
|
295 |
+
if (!spaceId) {
|
296 |
+
throw new Error('无法从space_view_pointers中提取spaceId');
|
297 |
+
}
|
298 |
+
|
299 |
+
// 清理全局对象
|
300 |
+
this.cleanupGlobalObjects();
|
301 |
+
|
302 |
+
return {
|
303 |
+
success: true,
|
304 |
+
userId,
|
305 |
+
spaceId
|
306 |
+
};
|
307 |
+
|
308 |
+
} catch (error) {
|
309 |
+
// 清理全局对象
|
310 |
+
this.cleanupGlobalObjects();
|
311 |
+
|
312 |
+
// 重试逻辑
|
313 |
+
if (retryCount < this.maxRetries && error.message !== '未授权,cookie无效') {
|
314 |
+
logger.warning(`获取Notion ID失败,正在重试 (${retryCount + 1}/${this.maxRetries}): ${error.message}`);
|
315 |
+
return await this.fetchNotionIds(cookie, retryCount + 1);
|
316 |
+
}
|
317 |
+
|
318 |
+
return {
|
319 |
+
success: false,
|
320 |
+
error: error.message
|
321 |
+
};
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* 清理全局对象
|
327 |
+
*/
|
328 |
+
cleanupGlobalObjects() {
|
329 |
+
try {
|
330 |
+
if (global.window) delete global.window;
|
331 |
+
if (global.document) delete global.document;
|
332 |
+
|
333 |
+
// 安全地删除navigator
|
334 |
+
if (global.navigator) {
|
335 |
+
try {
|
336 |
+
delete global.navigator;
|
337 |
+
} catch (navError) {
|
338 |
+
// 如果无法删除,尝试将其设置为undefined
|
339 |
+
try {
|
340 |
+
Object.defineProperty(global, 'navigator', {
|
341 |
+
value: undefined,
|
342 |
+
writable: true,
|
343 |
+
configurable: true
|
344 |
+
});
|
345 |
+
} catch (defineError) {
|
346 |
+
logger.warning(`无法清理navigator: ${defineError.message}`);
|
347 |
+
}
|
348 |
+
}
|
349 |
+
}
|
350 |
+
} catch (cleanupError) {
|
351 |
+
logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* 获取下一个可用的cookie及其ID
|
357 |
+
* @returns {Object|null} - cookie及其对应的ID,如果没有可用cookie则返回null
|
358 |
+
*/
|
359 |
+
getNext() {
|
360 |
+
if (!this.initialized || this.cookieEntries.length === 0) {
|
361 |
+
return null;
|
362 |
+
}
|
363 |
+
|
364 |
+
// 轮询选择下一个cookie
|
365 |
+
const entry = this.cookieEntries[this.currentIndex];
|
366 |
+
|
367 |
+
// 更新索引,实现轮询
|
368 |
+
this.currentIndex = (this.currentIndex + 1) % this.cookieEntries.length;
|
369 |
+
|
370 |
+
// 更新最后使用时间
|
371 |
+
entry.lastUsed = Date.now();
|
372 |
+
|
373 |
+
return {
|
374 |
+
cookie: entry.cookie,
|
375 |
+
spaceId: entry.spaceId,
|
376 |
+
userId: entry.userId
|
377 |
+
};
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* 标记cookie为无效
|
382 |
+
* @param {string} userId - 用户ID
|
383 |
+
*/
|
384 |
+
markAsInvalid(userId) {
|
385 |
+
const index = this.cookieEntries.findIndex(entry => entry.userId === userId);
|
386 |
+
if (index !== -1) {
|
387 |
+
this.cookieEntries[index].valid = false;
|
388 |
+
logger.warning(`已将用户ID为 ${userId} 的cookie标记为无效`);
|
389 |
+
|
390 |
+
// 过滤掉所有无效的cookie
|
391 |
+
this.cookieEntries = this.cookieEntries.filter(entry => entry.valid);
|
392 |
+
|
393 |
+
// 重置当前索引
|
394 |
+
if (this.cookieEntries.length > 0) {
|
395 |
+
this.currentIndex = 0;
|
396 |
+
}
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* 获取有效cookie的数量
|
402 |
+
* @returns {number} - 有效cookie的数量
|
403 |
+
*/
|
404 |
+
getValidCount() {
|
405 |
+
return this.cookieEntries.filter(entry => entry.valid).length;
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* 获取所有cookie的状态信息
|
410 |
+
* @returns {Array} - cookie状态数组
|
411 |
+
*/
|
412 |
+
getStatus() {
|
413 |
+
return this.cookieEntries.map((entry, index) => ({
|
414 |
+
index,
|
415 |
+
userId: entry.userId.substring(0, 8) + '...',
|
416 |
+
spaceId: entry.spaceId.substring(0, 8) + '...',
|
417 |
+
valid: entry.valid,
|
418 |
+
lastUsed: entry.lastUsed ? new Date(entry.lastUsed).toLocaleString() : 'never'
|
419 |
+
}));
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
export const cookieManager = new CookieManager();
|
src/ProxyPool.js
ADDED
@@ -0,0 +1,630 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import axios from 'axios';
|
2 |
+
|
3 |
+
/**
|
4 |
+
* 代理池类,用于管理和提供HTTP代理
|
5 |
+
*/
|
6 |
+
class ProxyPool {
|
7 |
+
/**
|
8 |
+
* 创建代理池实例
|
9 |
+
* @param {Object} options - 配置选项
|
10 |
+
* @param {number} options.targetCount - 目标代理数量,默认20
|
11 |
+
* @param {number} options.batchSize - 每次获取的代理数量,默认20
|
12 |
+
* @param {number} options.testTimeout - 测试代理超时时间(毫秒),默认5000
|
13 |
+
* @param {number} options.requestTimeout - 请求目标网站超时时间(毫秒),默认10000
|
14 |
+
* @param {string} options.targetUrl - 目标网站URL,默认'https://www.notion.so'
|
15 |
+
* @param {number} options.concurrentRequests - 并发请求数量,默认10
|
16 |
+
* @param {number} options.minThreshold - 可用代理数量低于此阈值时自动补充,默认5
|
17 |
+
* @param {number} options.checkInterval - 检查代理池状态的时间间隔(毫秒),默认30000
|
18 |
+
* @param {string} options.proxyProtocol - 代理协议,默认'http'
|
19 |
+
* @param {number} options.maxRefillAttempts - 最大补充尝试次数,默认20
|
20 |
+
* @param {number} options.retryDelay - 重试延迟(毫秒),默认1000
|
21 |
+
* @param {boolean} options.useCache - 是否使用缓存,默认true
|
22 |
+
* @param {number} options.cacheExpiry - 缓存过期时间(毫秒),默认3600000 (1小时)
|
23 |
+
* @param {string} options.logLevel - 日志级别,可选值:'debug', 'info', 'warn', 'error', 'none',默认'info'
|
24 |
+
*/
|
25 |
+
constructor(options = {}) {
|
26 |
+
// 配置参数
|
27 |
+
this.targetCount = options.targetCount || 20;
|
28 |
+
this.batchSize = options.batchSize || 20;
|
29 |
+
this.testTimeout = options.testTimeout || 5000;
|
30 |
+
this.requestTimeout = options.requestTimeout || 10000;
|
31 |
+
this.targetUrl = options.targetUrl || 'https://www.notion.so';
|
32 |
+
this.concurrentRequests = options.concurrentRequests || 10;
|
33 |
+
this.minThreshold = options.minThreshold || 5;
|
34 |
+
this.checkInterval = options.checkInterval || 30000; // 默认30秒检查一次
|
35 |
+
this.proxyProtocol = options.proxyProtocol || 'http';
|
36 |
+
this.maxRefillAttempts = options.maxRefillAttempts || 20; // 减少最大尝试次数
|
37 |
+
this.retryDelay = options.retryDelay || 1000; // 减少重试延迟
|
38 |
+
this.useCache = options.useCache !== undefined ? options.useCache : true;
|
39 |
+
this.cacheExpiry = options.cacheExpiry || 3600000; // 默认1小时
|
40 |
+
this.logLevel = options.logLevel || 'info'; // 默认日志级别为info
|
41 |
+
|
42 |
+
// 内部状态
|
43 |
+
this.availableProxies = [];
|
44 |
+
this.currentIndex = 0;
|
45 |
+
this.isInitialized = false;
|
46 |
+
this.isRefilling = false;
|
47 |
+
this.checkTimer = null;
|
48 |
+
this.proxyCache = new Map(); // 缓存验证过的代理
|
49 |
+
|
50 |
+
// 日志级别权重
|
51 |
+
this.logLevels = {
|
52 |
+
'debug': 0,
|
53 |
+
'info': 1,
|
54 |
+
'warn': 2,
|
55 |
+
'error': 3,
|
56 |
+
'none': 4
|
57 |
+
};
|
58 |
+
|
59 |
+
// 绑定方法
|
60 |
+
this.getProxy = this.getProxy.bind(this);
|
61 |
+
this.removeProxy = this.removeProxy.bind(this);
|
62 |
+
this.checkAndRefill = this.checkAndRefill.bind(this);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* 根据设置的日志级别输出日志
|
67 |
+
* @param {string} level - 日志级别
|
68 |
+
* @param {...any} args - 日志参数
|
69 |
+
*/
|
70 |
+
log(level, ...args) {
|
71 |
+
if (this.logLevels[level] >= this.logLevels[this.logLevel]) {
|
72 |
+
if (level === 'error') {
|
73 |
+
console.error(...args);
|
74 |
+
} else if (level === 'warn') {
|
75 |
+
console.warn(...args);
|
76 |
+
} else if (level === 'info' || level === 'debug') {
|
77 |
+
console.log(...args);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* 初始化代理池
|
84 |
+
* @returns {Promise<void>}
|
85 |
+
*/
|
86 |
+
async initialize() {
|
87 |
+
if (this.isInitialized) return;
|
88 |
+
|
89 |
+
this.log('info', `初始化代理池,目标数量: ${this.targetCount}`);
|
90 |
+
await this.refillProxies();
|
91 |
+
|
92 |
+
// 设置定时检查
|
93 |
+
this.checkTimer = setInterval(this.checkAndRefill, this.checkInterval);
|
94 |
+
|
95 |
+
this.isInitialized = true;
|
96 |
+
this.log('info', `代理池初始化完成,当前可用代理数量: ${this.availableProxies.length}`);
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* 停止代理池服务
|
101 |
+
*/
|
102 |
+
stop() {
|
103 |
+
if (this.checkTimer) {
|
104 |
+
clearInterval(this.checkTimer);
|
105 |
+
this.checkTimer = null;
|
106 |
+
}
|
107 |
+
this.log('info', '代理池服务已停止');
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* 检查并补充代理
|
112 |
+
*/
|
113 |
+
async checkAndRefill() {
|
114 |
+
if (this.availableProxies.length <= this.minThreshold && !this.isRefilling) {
|
115 |
+
this.log('info', `可用代理数量(${this.availableProxies.length})低于阈值(${this.minThreshold}),开始补充代理`);
|
116 |
+
await this.refillProxies();
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* 补充代理到目标数量
|
122 |
+
* @returns {Promise<void>}
|
123 |
+
*/
|
124 |
+
async refillProxies() {
|
125 |
+
if (this.isRefilling) return;
|
126 |
+
|
127 |
+
this.isRefilling = true;
|
128 |
+
this.log('info', `开始补充代理,当前数量: ${this.availableProxies.length},目标数量: ${this.targetCount}`);
|
129 |
+
|
130 |
+
let attempts = 0;
|
131 |
+
|
132 |
+
try {
|
133 |
+
// 计算需要补充的代理数量
|
134 |
+
const neededProxies = this.targetCount - this.availableProxies.length;
|
135 |
+
|
136 |
+
// 优先检查缓存中的代理
|
137 |
+
if (this.useCache && this.proxyCache.size > 0) {
|
138 |
+
await this.tryUsingCachedProxies(neededProxies);
|
139 |
+
}
|
140 |
+
|
141 |
+
// 如果缓存中的代理不足,继续获取新代理
|
142 |
+
while (this.availableProxies.length < this.targetCount && attempts < this.maxRefillAttempts) {
|
143 |
+
attempts++;
|
144 |
+
|
145 |
+
this.log('debug', `补充尝试 #${attempts},当前可用代理: ${this.availableProxies.length}/${this.targetCount}`);
|
146 |
+
|
147 |
+
// 计算本次需要获取的批次大小
|
148 |
+
const remainingNeeded = this.targetCount - this.availableProxies.length;
|
149 |
+
const batchSizeNeeded = Math.max(this.batchSize, remainingNeeded * 2); // 获取更多代理以提高成功率
|
150 |
+
|
151 |
+
// 获取代理
|
152 |
+
const proxies = await this.getProxiesFromProvider(batchSizeNeeded);
|
153 |
+
|
154 |
+
if (proxies.length === 0) {
|
155 |
+
this.log('debug', `没有获取到代理,等待${this.retryDelay/1000}秒后重试...`);
|
156 |
+
await new Promise(resolve => setTimeout(resolve, this.retryDelay));
|
157 |
+
continue;
|
158 |
+
}
|
159 |
+
|
160 |
+
// 过滤掉已有的代理
|
161 |
+
const newProxies = this.filterExistingProxies(proxies);
|
162 |
+
|
163 |
+
if (newProxies.length === 0) {
|
164 |
+
this.log('debug', '所有获取的代理都已存在,继续获取新代理...');
|
165 |
+
continue;
|
166 |
+
}
|
167 |
+
|
168 |
+
// 测试代理
|
169 |
+
const results = await this.testProxiesConcurrently(newProxies);
|
170 |
+
|
171 |
+
// 添加可用代理
|
172 |
+
this.addValidProxies(results);
|
173 |
+
|
174 |
+
// 如果已经获取到足够的代理,提前结束
|
175 |
+
if (this.availableProxies.length >= this.targetCount) {
|
176 |
+
break;
|
177 |
+
}
|
178 |
+
|
179 |
+
// 如果还没补充到足够的代理,等待一段时间再继续
|
180 |
+
if (this.availableProxies.length < this.targetCount) {
|
181 |
+
await new Promise(resolve => setTimeout(resolve, this.retryDelay));
|
182 |
+
}
|
183 |
+
}
|
184 |
+
} catch (error) {
|
185 |
+
this.log('error', '补充代理过程中出错:', error);
|
186 |
+
} finally {
|
187 |
+
this.isRefilling = false;
|
188 |
+
|
189 |
+
if (this.availableProxies.length >= this.targetCount) {
|
190 |
+
this.log('info', `代理补充完成,当前可用代理: ${this.availableProxies.length}/${this.targetCount}`);
|
191 |
+
} else {
|
192 |
+
this.log('info', `已达到最大尝试次数 ${this.maxRefillAttempts},当前可用代理: ${this.availableProxies.length}/${this.targetCount}`);
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* 尝试使用缓存中的代理
|
199 |
+
* @param {number} neededProxies - 需要的代理数量
|
200 |
+
*/
|
201 |
+
async tryUsingCachedProxies(neededProxies) {
|
202 |
+
const now = Date.now();
|
203 |
+
const cachedProxies = [];
|
204 |
+
|
205 |
+
// 筛选未过期的缓存代理
|
206 |
+
for (const [proxyKey, data] of this.proxyCache.entries()) {
|
207 |
+
if (now - data.timestamp < this.cacheExpiry && data.valid) {
|
208 |
+
cachedProxies.push(proxyKey);
|
209 |
+
|
210 |
+
if (cachedProxies.length >= neededProxies) {
|
211 |
+
break;
|
212 |
+
}
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
if (cachedProxies.length > 0) {
|
217 |
+
this.log('debug', `从缓存中找到 ${cachedProxies.length} 个可能可用的代理`);
|
218 |
+
|
219 |
+
// 验证缓存的代理是否仍然可用
|
220 |
+
const results = await this.testProxiesConcurrently(cachedProxies);
|
221 |
+
this.addValidProxies(results);
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* 过滤掉已存在的代理
|
227 |
+
* @param {Array<string>} proxies - 代理列表
|
228 |
+
* @returns {Array<string>} - 新代理列表
|
229 |
+
*/
|
230 |
+
filterExistingProxies(proxies) {
|
231 |
+
return proxies.filter(proxy => {
|
232 |
+
const proxyParts = proxy.split(':');
|
233 |
+
const ip = proxyParts[0];
|
234 |
+
const port = proxyParts[1];
|
235 |
+
|
236 |
+
// 如果有用户名和密码,也需要比较这些信息
|
237 |
+
if (proxyParts.length >= 4) {
|
238 |
+
const username = proxyParts[2];
|
239 |
+
const password = proxyParts[3];
|
240 |
+
return !this.availableProxies.some(p =>
|
241 |
+
p.ip === ip &&
|
242 |
+
p.port === port &&
|
243 |
+
p.username === username &&
|
244 |
+
p.password === password
|
245 |
+
);
|
246 |
+
}
|
247 |
+
|
248 |
+
// 没有用户名和密码时,只比较IP和端口
|
249 |
+
return !this.availableProxies.some(p => p.ip === ip && p.port === port);
|
250 |
+
});
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* 添加有效的代理到代理池
|
255 |
+
* @param {Array<{proxy: string, result: boolean}>} results - 测试结果
|
256 |
+
*/
|
257 |
+
addValidProxies(results) {
|
258 |
+
for (const { proxy, result } of results) {
|
259 |
+
if (result) {
|
260 |
+
const proxyParts = proxy.split(':');
|
261 |
+
const ip = proxyParts[0];
|
262 |
+
const port = proxyParts[1];
|
263 |
+
|
264 |
+
// 检查是否已存在
|
265 |
+
let exists = false;
|
266 |
+
|
267 |
+
if (proxyParts.length >= 4) {
|
268 |
+
// 有用户名和密码时,同时比较IP、端口、用户名和密码
|
269 |
+
const username = proxyParts[2];
|
270 |
+
const password = proxyParts[3];
|
271 |
+
exists = this.availableProxies.some(p =>
|
272 |
+
p.ip === ip &&
|
273 |
+
p.port === port &&
|
274 |
+
p.username === username &&
|
275 |
+
p.password === password
|
276 |
+
);
|
277 |
+
} else {
|
278 |
+
// 没有用户名和密码时,只比较IP和端口
|
279 |
+
exists = this.availableProxies.some(p => p.ip === ip && p.port === port);
|
280 |
+
}
|
281 |
+
|
282 |
+
if (!exists) {
|
283 |
+
const proxyObj = {
|
284 |
+
ip,
|
285 |
+
port,
|
286 |
+
protocol: this.proxyProtocol,
|
287 |
+
full: `${this.proxyProtocol}://${proxy}`,
|
288 |
+
addedAt: new Date().toISOString()
|
289 |
+
};
|
290 |
+
|
291 |
+
// 如果有用户名和密码,添加到代理对象
|
292 |
+
if (proxyParts.length >= 4) {
|
293 |
+
proxyObj.username = proxyParts[2];
|
294 |
+
proxyObj.password = proxyParts[3];
|
295 |
+
proxyObj.full = `${this.proxyProtocol}://${proxyObj.username}:${proxyObj.password}@${ip}:${port}`;
|
296 |
+
}
|
297 |
+
|
298 |
+
this.availableProxies.push(proxyObj);
|
299 |
+
|
300 |
+
// 添加到缓存
|
301 |
+
if (this.useCache) {
|
302 |
+
this.proxyCache.set(proxy, {
|
303 |
+
valid: true,
|
304 |
+
timestamp: Date.now()
|
305 |
+
});
|
306 |
+
}
|
307 |
+
|
308 |
+
this.log('debug', `成功添加代理: ${proxyObj.full},当前可用代理: ${this.availableProxies.length}/${this.targetCount}`);
|
309 |
+
|
310 |
+
if (this.availableProxies.length >= this.targetCount) {
|
311 |
+
break;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
} else if (this.useCache) {
|
315 |
+
// 记录无效代理到缓存
|
316 |
+
this.proxyCache.set(proxy, {
|
317 |
+
valid: false,
|
318 |
+
timestamp: Date.now()
|
319 |
+
});
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* 从代理服务获取代理URL
|
326 |
+
* @param {number} count - 请求的代理数量
|
327 |
+
* @returns {Promise<Array<string>>} - 代理URL列表
|
328 |
+
*/
|
329 |
+
async getProxiesFromProvider(count = null) {
|
330 |
+
try {
|
331 |
+
const requestCount = count || this.batchSize;
|
332 |
+
// 限制请求数量最大为10
|
333 |
+
const actualCount = Math.min(requestCount, 10);
|
334 |
+
const url = `https://proxy.doudouzi.me/random/us?number=${actualCount}&protocol=${this.proxyProtocol}&type=json`;
|
335 |
+
this.log('debug', `正在获取代理,URL: ${url}`);
|
336 |
+
|
337 |
+
const response = await axios.get(url, {
|
338 |
+
timeout: 10000,
|
339 |
+
validateStatus: status => true
|
340 |
+
});
|
341 |
+
|
342 |
+
if (response.data) {
|
343 |
+
// 解析返回的数据格式
|
344 |
+
const proxyDataArray = response.data.trim().split('\n').filter(line => line.trim() !== '');
|
345 |
+
const proxies = [];
|
346 |
+
|
347 |
+
for (const line of proxyDataArray) {
|
348 |
+
try {
|
349 |
+
const proxyData = JSON.parse(line);
|
350 |
+
if (proxyData.ip && proxyData.port) {
|
351 |
+
// 如果有用户名和密码,则使用认证格式
|
352 |
+
if (proxyData.username && proxyData.password) {
|
353 |
+
proxies.push(`${proxyData.ip}:${proxyData.port}:${proxyData.username}:${proxyData.password}`);
|
354 |
+
} else {
|
355 |
+
proxies.push(`${proxyData.ip}:${proxyData.port}`);
|
356 |
+
}
|
357 |
+
}
|
358 |
+
} catch (err) {
|
359 |
+
this.log('error', '解析代理数据出错:', err.message);
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
this.log('debug', `成功获取 ${proxies.length} 个代理`);
|
364 |
+
return proxies;
|
365 |
+
} else {
|
366 |
+
this.log('error', '获取代理失败: 返回数据格式不正确');
|
367 |
+
return [];
|
368 |
+
}
|
369 |
+
} catch (error) {
|
370 |
+
this.log('error', '获取代理出错:', error.message);
|
371 |
+
return [];
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* 并发测试多个代理
|
377 |
+
* @param {Array<string>} proxies - 代理列表
|
378 |
+
* @returns {Promise<Array<{proxy: string, result: boolean}>>} - 测试结果
|
379 |
+
*/
|
380 |
+
async testProxiesConcurrently(proxies) {
|
381 |
+
const results = [];
|
382 |
+
const remainingNeeded = this.targetCount - this.availableProxies.length;
|
383 |
+
|
384 |
+
// 增加并发数以加快处理速度
|
385 |
+
const concurrentRequests = Math.min(this.concurrentRequests * 2, 20);
|
386 |
+
|
387 |
+
// 分批处理代理
|
388 |
+
for (let i = 0; i < proxies.length; i += concurrentRequests) {
|
389 |
+
const batch = proxies.slice(i, i + concurrentRequests);
|
390 |
+
const promises = batch.map(proxy => {
|
391 |
+
// 检查缓存中是否有近期验证过的结果
|
392 |
+
if (this.useCache && this.proxyCache.has(proxy)) {
|
393 |
+
const cachedResult = this.proxyCache.get(proxy);
|
394 |
+
const isFresh = (Date.now() - cachedResult.timestamp) < this.cacheExpiry;
|
395 |
+
|
396 |
+
if (isFresh) {
|
397 |
+
// 使用缓存结果,避免重复测试
|
398 |
+
return Promise.resolve({ proxy, result: cachedResult.valid });
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
return this.testProxy(proxy)
|
403 |
+
.then(result => ({ proxy, result }))
|
404 |
+
.catch(() => ({ proxy, result: false }));
|
405 |
+
});
|
406 |
+
|
407 |
+
const batchResults = await Promise.all(promises);
|
408 |
+
results.push(...batchResults);
|
409 |
+
|
410 |
+
// 如果已经找到足够的代理,提前结束测试
|
411 |
+
const successCount = results.filter(item => item.result).length;
|
412 |
+
if (successCount >= remainingNeeded) {
|
413 |
+
break;
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
return results;
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* 测试代理是否可用
|
422 |
+
* @param {string} proxyUrl - 代理URL
|
423 |
+
* @returns {Promise<boolean>} - 代理是否可用
|
424 |
+
*/
|
425 |
+
async testProxy(proxyUrl) {
|
426 |
+
try {
|
427 |
+
// 创建代理配置
|
428 |
+
const proxyParts = proxyUrl.split(':');
|
429 |
+
const proxyConfig = {
|
430 |
+
host: proxyParts[0],
|
431 |
+
port: parseInt(proxyParts[1]),
|
432 |
+
protocol: this.proxyProtocol
|
433 |
+
};
|
434 |
+
|
435 |
+
// 如果有用户名和密码,添加认证信息
|
436 |
+
if (proxyParts.length >= 4) {
|
437 |
+
proxyConfig.auth = {
|
438 |
+
username: proxyParts[2],
|
439 |
+
password: proxyParts[3]
|
440 |
+
};
|
441 |
+
}
|
442 |
+
|
443 |
+
// 发送请求到目标网站
|
444 |
+
const response = await axios.get(this.targetUrl, {
|
445 |
+
proxy: proxyConfig,
|
446 |
+
headers: {
|
447 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
448 |
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
449 |
+
'Accept-Language': 'en-US,en;q=0.5',
|
450 |
+
'Connection': 'keep-alive',
|
451 |
+
'Upgrade-Insecure-Requests': '1'
|
452 |
+
},
|
453 |
+
timeout: this.requestTimeout,
|
454 |
+
validateStatus: status => true,
|
455 |
+
maxRedirects: 10,
|
456 |
+
followRedirect: true
|
457 |
+
});
|
458 |
+
|
459 |
+
// 检查响应是否包含目标网站特有的内容
|
460 |
+
const isTargetContent = response.data &&
|
461 |
+
(typeof response.data === 'string') &&
|
462 |
+
(response.data.includes('notion') ||
|
463 |
+
response.data.includes('Notion'));
|
464 |
+
|
465 |
+
const isValid = response.status === 200 && isTargetContent;
|
466 |
+
|
467 |
+
if (isValid) {
|
468 |
+
this.log('debug', `代理 ${proxyUrl} 请求目标网站成功,状态码: ${response.status}`);
|
469 |
+
} else {
|
470 |
+
this.log('debug', `代理 ${proxyUrl} 请求目标网站失败,状态码: ${response.status}`);
|
471 |
+
}
|
472 |
+
|
473 |
+
return isValid;
|
474 |
+
} catch (error) {
|
475 |
+
this.log('debug', `代理 ${proxyUrl} 请求出错: ${error.message}`);
|
476 |
+
return false;
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* 获取一个可用代理
|
482 |
+
* @returns {Object|null} - 代理对象,如果没有可用代理则返回null
|
483 |
+
*/
|
484 |
+
getProxy() {
|
485 |
+
if (this.availableProxies.length === 0) {
|
486 |
+
this.log('warn', '没有可用代理');
|
487 |
+
return null;
|
488 |
+
}
|
489 |
+
|
490 |
+
// 轮询方式获取代理
|
491 |
+
const proxy = this.availableProxies[this.currentIndex];
|
492 |
+
this.currentIndex = (this.currentIndex + 1) % this.availableProxies.length;
|
493 |
+
|
494 |
+
return proxy;
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* 移除指定代理
|
499 |
+
* @param {string} ip - 代理IP
|
500 |
+
* @param {string|number} port - 代理端口
|
501 |
+
* @returns {boolean} - 是否成功移除
|
502 |
+
*/
|
503 |
+
removeProxy(ip, port) {
|
504 |
+
const portStr = port.toString();
|
505 |
+
const initialLength = this.availableProxies.length;
|
506 |
+
|
507 |
+
// 找到要移除的代理
|
508 |
+
const proxyToRemove = this.availableProxies.find(
|
509 |
+
proxy => proxy.ip === ip && proxy.port === portStr
|
510 |
+
);
|
511 |
+
|
512 |
+
if (proxyToRemove) {
|
513 |
+
// 更新缓存,标记为无效
|
514 |
+
if (this.useCache) {
|
515 |
+
const proxyKey = `${ip}:${portStr}`;
|
516 |
+
this.proxyCache.set(proxyKey, { valid: false, timestamp: Date.now() });
|
517 |
+
}
|
518 |
+
}
|
519 |
+
|
520 |
+
this.availableProxies = this.availableProxies.filter(
|
521 |
+
proxy => !(proxy.ip === ip && proxy.port === portStr)
|
522 |
+
);
|
523 |
+
|
524 |
+
// 重置当前索引,确保不会越界
|
525 |
+
if (this.currentIndex >= this.availableProxies.length && this.availableProxies.length > 0) {
|
526 |
+
this.currentIndex = 0;
|
527 |
+
}
|
528 |
+
|
529 |
+
const removed = initialLength > this.availableProxies.length;
|
530 |
+
|
531 |
+
if (removed) {
|
532 |
+
this.log('debug', `已移除代理 ${ip}:${port},当前可用代理: ${this.availableProxies.length}`);
|
533 |
+
} else {
|
534 |
+
this.log('debug', `未找到要移除的代理 ${ip}:${port}`);
|
535 |
+
}
|
536 |
+
|
537 |
+
// 如果移除后代理数量低于阈值,触发补充
|
538 |
+
this.checkAndRefill();
|
539 |
+
|
540 |
+
return removed;
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* 获取所有可用代理
|
545 |
+
* @returns {Array<Object>} - 代理对象数组
|
546 |
+
*/
|
547 |
+
getAllProxies() {
|
548 |
+
return [...this.availableProxies];
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* 获取可用代理数量
|
553 |
+
* @returns {number} - 代理数量
|
554 |
+
*/
|
555 |
+
getCount() {
|
556 |
+
return this.availableProxies.length;
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* 清理过期的缓存条目
|
561 |
+
*/
|
562 |
+
cleanupCache() {
|
563 |
+
if (!this.useCache) return;
|
564 |
+
|
565 |
+
const now = Date.now();
|
566 |
+
let cleanupCount = 0;
|
567 |
+
|
568 |
+
for (const [key, data] of this.proxyCache.entries()) {
|
569 |
+
if (now - data.timestamp > this.cacheExpiry) {
|
570 |
+
this.proxyCache.delete(key);
|
571 |
+
cleanupCount++;
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
if (cleanupCount > 0) {
|
576 |
+
this.log('debug', `清理了 ${cleanupCount} 个过期的缓存代理`);
|
577 |
+
}
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
// 使用示例
|
582 |
+
async function example() {
|
583 |
+
// 创建代理池实例
|
584 |
+
const proxyPool = new ProxyPool({
|
585 |
+
targetCount: 10, // 目标保持10个代理
|
586 |
+
minThreshold: 3, // 当可用代理少于3个时,自动补充
|
587 |
+
checkInterval: 60000, // 每60秒检查一次
|
588 |
+
targetUrl: 'https://www.notion.so',
|
589 |
+
concurrentRequests: 15, // 增加并发请求数
|
590 |
+
useCache: true, // 启用缓存
|
591 |
+
maxRefillAttempts: 15, // 减少最大尝试次数
|
592 |
+
retryDelay: 1000, // 减少重试延迟
|
593 |
+
logLevel: 'info' // 设置日志级别
|
594 |
+
});
|
595 |
+
|
596 |
+
// 初始化代理池
|
597 |
+
await proxyPool.initialize();
|
598 |
+
|
599 |
+
// 获取一个代理
|
600 |
+
const proxy = proxyPool.getProxy();
|
601 |
+
console.log('获取到代理:', proxy);
|
602 |
+
|
603 |
+
// 模拟使用一段时间后,移除一个代理
|
604 |
+
setTimeout(() => {
|
605 |
+
if (proxy) {
|
606 |
+
proxyPool.removeProxy(proxy.ip, proxy.port);
|
607 |
+
}
|
608 |
+
|
609 |
+
// 获取所有代理
|
610 |
+
const allProxies = proxyPool.getAllProxies();
|
611 |
+
console.log(`当前所有代理(${allProxies.length}):`, allProxies);
|
612 |
+
|
613 |
+
// 使用完毕后停止服务
|
614 |
+
setTimeout(() => {
|
615 |
+
proxyPool.stop();
|
616 |
+
console.log('代理池示例运行完毕');
|
617 |
+
}, 5000);
|
618 |
+
}, 5000);
|
619 |
+
}
|
620 |
+
|
621 |
+
// 如果直接运行此文件,则执行示例
|
622 |
+
if (typeof require !== 'undefined' && require.main === module) {
|
623 |
+
example().catch(err => console.error('示例运行出错:', err));
|
624 |
+
}
|
625 |
+
|
626 |
+
// 导出 ProxyPool 类和实例
|
627 |
+
export default ProxyPool;
|
628 |
+
export const proxyPool = new ProxyPool({
|
629 |
+
logLevel: 'info' // 默认导出的实例使用info级别的日志
|
630 |
+
});
|
src/ProxyServer.js
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { spawn } from 'child_process';
|
2 |
+
import { fileURLToPath } from 'url';
|
3 |
+
import { dirname, join } from 'path';
|
4 |
+
import fs from 'fs';
|
5 |
+
import os from 'os';
|
6 |
+
import dotenv from 'dotenv';
|
7 |
+
import chalk from 'chalk';
|
8 |
+
|
9 |
+
// 获取当前文件的目录路径
|
10 |
+
const __filename = fileURLToPath(import.meta.url);
|
11 |
+
const __dirname = dirname(__filename);
|
12 |
+
|
13 |
+
// 加载环境变量
|
14 |
+
dotenv.config({ path: join(dirname(__dirname), '.env') });
|
15 |
+
|
16 |
+
// 日志配置
|
17 |
+
const logger = {
|
18 |
+
info: (message) => console.log(chalk.blue(`[ProxyServer] ${message}`)),
|
19 |
+
error: (message) => console.error(chalk.red(`[ProxyServer] ${message}`)),
|
20 |
+
warning: (message) => console.warn(chalk.yellow(`[ProxyServer] ${message}`)),
|
21 |
+
success: (message) => console.log(chalk.green(`[ProxyServer] ${message}`)),
|
22 |
+
};
|
23 |
+
|
24 |
+
class ProxyServer {
|
25 |
+
constructor() {
|
26 |
+
this.proxyProcess = null;
|
27 |
+
this.platform = process.env.PROXY_SERVER_PLATFORM || 'auto';
|
28 |
+
this.port = process.env.PROXY_SERVER_PORT || 10655;
|
29 |
+
this.logPath = process.env.PROXY_SERVER_LOG_PATH || './proxy_server.log';
|
30 |
+
this.enabled = process.env.ENABLE_PROXY_SERVER === 'true';
|
31 |
+
this.proxyAuthToken = process.env.PROXY_AUTH_TOKEN || 'default_token';
|
32 |
+
this.logStream = null;
|
33 |
+
}
|
34 |
+
|
35 |
+
// 获取当前系统平台
|
36 |
+
detectPlatform() {
|
37 |
+
if (this.platform !== 'auto') {
|
38 |
+
return this.platform;
|
39 |
+
}
|
40 |
+
|
41 |
+
const platform = os.platform();
|
42 |
+
const arch = os.arch();
|
43 |
+
|
44 |
+
if (platform === 'win32') {
|
45 |
+
return 'windows';
|
46 |
+
} else if (platform === 'linux') {
|
47 |
+
if (arch === 'arm64') {
|
48 |
+
return 'android';
|
49 |
+
} else {
|
50 |
+
return 'linux';
|
51 |
+
}
|
52 |
+
} else if (platform === 'android') {
|
53 |
+
return 'android';
|
54 |
+
} else {
|
55 |
+
logger.warning(`未知平台: ${platform}, ${arch}, 默认使用linux版本`);
|
56 |
+
return 'linux';
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
// 获取代理服务器可执行文件路径
|
61 |
+
getProxyServerPath() {
|
62 |
+
const platform = this.detectPlatform();
|
63 |
+
const proxyDir = join(__dirname, 'proxy');
|
64 |
+
|
65 |
+
switch (platform) {
|
66 |
+
case 'windows':
|
67 |
+
return join(proxyDir, 'chrome_proxy_server_windows_amd64.exe');
|
68 |
+
case 'linux':
|
69 |
+
return join(proxyDir, 'chrome_proxy_server_linux_amd64');
|
70 |
+
case 'android':
|
71 |
+
return join(proxyDir, 'chrome_proxy_server_android_arm64');
|
72 |
+
default:
|
73 |
+
logger.error(`不支持的平台: ${platform}`);
|
74 |
+
return null;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
// 启动代理服务器
|
79 |
+
async start() {
|
80 |
+
if (!this.enabled) {
|
81 |
+
logger.info('代理服务器未启用,跳过启动');
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
if (this.proxyProcess) {
|
86 |
+
logger.warning('代理服务器已经在运行中');
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
const proxyServerPath = this.getProxyServerPath();
|
91 |
+
if (!proxyServerPath) {
|
92 |
+
logger.error('无法获取代理服务器路径');
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
try {
|
97 |
+
// 确保可执行文件有执行权限(在Linux/Android上)
|
98 |
+
if (this.detectPlatform() !== 'windows') {
|
99 |
+
try {
|
100 |
+
fs.chmodSync(proxyServerPath, 0o755);
|
101 |
+
} catch (err) {
|
102 |
+
logger.warning(`无法设置执行权限: ${err.message}`);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
// 创建日志文件
|
107 |
+
this.logStream = fs.createWriteStream(this.logPath, { flags: 'a' });
|
108 |
+
|
109 |
+
// 修复 stdio 参数问题
|
110 |
+
// 启动代理服务器进程
|
111 |
+
this.proxyProcess = spawn(proxyServerPath, [
|
112 |
+
'--port', this.port.toString(),
|
113 |
+
'--token', this.proxyAuthToken
|
114 |
+
], {
|
115 |
+
stdio: ['ignore', 'pipe', 'pipe'], // 使用pipe而不是直接传递流
|
116 |
+
detached: false
|
117 |
+
});
|
118 |
+
|
119 |
+
// 将进程的输出重定向到日志文件
|
120 |
+
if (this.proxyProcess.stdout) {
|
121 |
+
this.proxyProcess.stdout.pipe(this.logStream);
|
122 |
+
}
|
123 |
+
|
124 |
+
if (this.proxyProcess.stderr) {
|
125 |
+
this.proxyProcess.stderr.pipe(this.logStream);
|
126 |
+
}
|
127 |
+
|
128 |
+
// 设置进程事件处理
|
129 |
+
this.proxyProcess.on('error', (err) => {
|
130 |
+
logger.error(`代理服务器启动失败: ${err.message}`);
|
131 |
+
this.proxyProcess = null;
|
132 |
+
if (this.logStream) {
|
133 |
+
this.logStream.end();
|
134 |
+
this.logStream = null;
|
135 |
+
}
|
136 |
+
});
|
137 |
+
|
138 |
+
this.proxyProcess.on('exit', (code, signal) => {
|
139 |
+
logger.info(`代理服务器已退出,退出码: ${code}, 信号: ${signal}`);
|
140 |
+
this.proxyProcess = null;
|
141 |
+
if (this.logStream) {
|
142 |
+
this.logStream.end();
|
143 |
+
this.logStream = null;
|
144 |
+
}
|
145 |
+
});
|
146 |
+
|
147 |
+
// 等待一段时间,确保服务器启动
|
148 |
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
149 |
+
|
150 |
+
if (this.proxyProcess && this.proxyProcess.exitCode === null) {
|
151 |
+
logger.success(`代理服务器已启动,端口: ${this.port}, 日志文件: ${this.logPath}`);
|
152 |
+
return true;
|
153 |
+
} else {
|
154 |
+
logger.error('代理服务器启动失败');
|
155 |
+
if (this.logStream) {
|
156 |
+
this.logStream.end();
|
157 |
+
this.logStream = null;
|
158 |
+
}
|
159 |
+
return false;
|
160 |
+
}
|
161 |
+
} catch (error) {
|
162 |
+
logger.error(`启动代理服务器时出错: ${error.message}`);
|
163 |
+
if (this.logStream) {
|
164 |
+
this.logStream.end();
|
165 |
+
this.logStream = null;
|
166 |
+
}
|
167 |
+
return false;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
// 停止代理服务器
|
172 |
+
stop() {
|
173 |
+
if (!this.proxyProcess) {
|
174 |
+
//logger.info('代理服务器已关闭');
|
175 |
+
return;
|
176 |
+
}
|
177 |
+
|
178 |
+
try {
|
179 |
+
// 在Windows上使用taskkill确保子进程也被终止
|
180 |
+
if (this.detectPlatform() === 'windows' && this.proxyProcess.pid) {
|
181 |
+
spawn('taskkill', ['/pid', this.proxyProcess.pid, '/f', '/t']);
|
182 |
+
} else {
|
183 |
+
// 在Linux/Android上使用kill信号
|
184 |
+
this.proxyProcess.kill('SIGTERM');
|
185 |
+
}
|
186 |
+
|
187 |
+
logger.success('代理服务器已停止');
|
188 |
+
} catch (error) {
|
189 |
+
logger.error(`停止代理服务器时出错: ${error.message}`);
|
190 |
+
} finally {
|
191 |
+
this.proxyProcess = null;
|
192 |
+
if (this.logStream) {
|
193 |
+
this.logStream.end();
|
194 |
+
this.logStream = null;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
// 创建单例
|
201 |
+
const proxyServer = new ProxyServer();
|
202 |
+
|
203 |
+
// 导出
|
204 |
+
export { proxyServer };
|
src/cookie-cli.js
ADDED
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env node
|
2 |
+
|
3 |
+
import { cookieManager } from './CookieManager.js';
|
4 |
+
import dotenv from 'dotenv';
|
5 |
+
import { fileURLToPath } from 'url';
|
6 |
+
import { dirname, join } from 'path';
|
7 |
+
import fs from 'fs';
|
8 |
+
import readline from 'readline';
|
9 |
+
import chalk from 'chalk';
|
10 |
+
|
11 |
+
// 获取当前文件的目录路径
|
12 |
+
const __filename = fileURLToPath(import.meta.url);
|
13 |
+
const __dirname = dirname(__filename);
|
14 |
+
|
15 |
+
// 加载环境变量
|
16 |
+
dotenv.config({ path: join(dirname(__dirname), '.env') });
|
17 |
+
|
18 |
+
// 日志配置
|
19 |
+
const logger = {
|
20 |
+
info: (message) => console.log(chalk.blue(`[信息] ${message}`)),
|
21 |
+
error: (message) => console.error(chalk.red(`[错误] ${message}`)),
|
22 |
+
warning: (message) => console.warn(chalk.yellow(`[警告] ${message}`)),
|
23 |
+
success: (message) => console.log(chalk.green(`[成功] ${message}`)),
|
24 |
+
};
|
25 |
+
|
26 |
+
// 创建readline接口
|
27 |
+
const rl = readline.createInterface({
|
28 |
+
input: process.stdin,
|
29 |
+
output: process.stdout
|
30 |
+
});
|
31 |
+
|
32 |
+
// 默认cookie文件路径
|
33 |
+
const DEFAULT_COOKIE_FILE = 'cookies.txt';
|
34 |
+
|
35 |
+
let isSaveCookie = false;
|
36 |
+
let isAddCookie = false;
|
37 |
+
|
38 |
+
// 显示帮助信息
|
39 |
+
function showHelp() {
|
40 |
+
console.log(chalk.cyan('Notion Cookie 管理工具'));
|
41 |
+
console.log(chalk.cyan('===================='));
|
42 |
+
console.log('');
|
43 |
+
console.log('可用命令:');
|
44 |
+
console.log(' help - 显示此帮助信息');
|
45 |
+
console.log(' list - 列出所有cookie');
|
46 |
+
console.log(' add - 添加新的cookie');
|
47 |
+
console.log(' validate - 验证所有cookie');
|
48 |
+
console.log(' remove - 删除指定cookie');
|
49 |
+
console.log(' save - 保存cookie到文件');
|
50 |
+
console.log(' load - 从文件加载cookie');
|
51 |
+
console.log(' exit - 退出程序');
|
52 |
+
console.log('');
|
53 |
+
}
|
54 |
+
|
55 |
+
// 列出所有cookie
|
56 |
+
async function listCookies() {
|
57 |
+
if (!cookieManager.initialized || cookieManager.getValidCount() === 0) {
|
58 |
+
logger.warning('没有可用的cookie,请先加载或添加cookie');
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
|
62 |
+
const status = cookieManager.getStatus();
|
63 |
+
console.log(chalk.cyan('\nCookie 列表:'));
|
64 |
+
console.log(chalk.cyan('==========='));
|
65 |
+
|
66 |
+
status.forEach((entry, idx) => {
|
67 |
+
const validMark = entry.valid ? chalk.green('✓') : chalk.red('✗');
|
68 |
+
console.log(`${idx + 1}. ${validMark} 用户ID: ${entry.userId}, 空间ID: ${entry.spaceId}, 上次使用: ${entry.lastUsed}`);
|
69 |
+
});
|
70 |
+
|
71 |
+
console.log(`\n共有 ${status.length} 个cookie,${cookieManager.getValidCount()} 个有效\n`);
|
72 |
+
}
|
73 |
+
|
74 |
+
// 添加新cookie
|
75 |
+
async function addCookie() {
|
76 |
+
return new Promise((resolve) => {
|
77 |
+
rl.question(chalk.yellow('请输入Notion cookie: '), async (cookie) => {
|
78 |
+
if (!cookie || cookie.trim() === '') {
|
79 |
+
logger.error('Cookie不能为空');
|
80 |
+
resolve();
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
logger.info('正在验证cookie...');
|
85 |
+
const result = await cookieManager.fetchNotionIds(cookie.trim());
|
86 |
+
|
87 |
+
if (result.success) {
|
88 |
+
// 如果cookie管理器尚未初始化,先初始化
|
89 |
+
if (!cookieManager.initialized) {
|
90 |
+
await cookieManager.initialize(cookie.trim());
|
91 |
+
} else {
|
92 |
+
// 已初始化,直接添加到现有条目
|
93 |
+
cookieManager.cookieEntries.push({
|
94 |
+
cookie: cookie.trim(),
|
95 |
+
spaceId: result.spaceId,
|
96 |
+
userId: result.userId,
|
97 |
+
valid: true,
|
98 |
+
lastUsed: 0
|
99 |
+
});
|
100 |
+
}
|
101 |
+
isAddCookie = true;
|
102 |
+
logger.success(`Cookie添加成功! 用户ID: ${result.userId}, 空间ID: ${result.spaceId}`);
|
103 |
+
|
104 |
+
} else {
|
105 |
+
logger.error(`Cookie验证失败: ${result.error}`);
|
106 |
+
}
|
107 |
+
|
108 |
+
resolve();
|
109 |
+
});
|
110 |
+
});
|
111 |
+
}
|
112 |
+
|
113 |
+
// 验证所有cookie
|
114 |
+
async function validateCookies() {
|
115 |
+
if (!cookieManager.initialized || cookieManager.cookieEntries.length === 0) {
|
116 |
+
logger.warning('没有可用的cookie,请先加载或添加cookie');
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
|
120 |
+
logger.info('开始验证所有cookie...');
|
121 |
+
|
122 |
+
const originalEntries = [...cookieManager.cookieEntries];
|
123 |
+
cookieManager.cookieEntries = [];
|
124 |
+
|
125 |
+
for (let i = 0; i < originalEntries.length; i++) {
|
126 |
+
const entry = originalEntries[i];
|
127 |
+
logger.info(`正在验证第 ${i+1}/${originalEntries.length} 个cookie...`);
|
128 |
+
|
129 |
+
const result = await cookieManager.fetchNotionIds(entry.cookie);
|
130 |
+
if (result.success) {
|
131 |
+
cookieManager.cookieEntries.push({
|
132 |
+
cookie: entry.cookie,
|
133 |
+
spaceId: result.spaceId,
|
134 |
+
userId: result.userId,
|
135 |
+
valid: true,
|
136 |
+
lastUsed: entry.lastUsed || 0
|
137 |
+
});
|
138 |
+
logger.success(`第 ${i+1} 个cookie验证成功`);
|
139 |
+
} else {
|
140 |
+
logger.error(`第 ${i+1} 个cookie验证失败: ${result.error}`);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
logger.info(`验证完成,共 ${originalEntries.length} 个cookie,${cookieManager.cookieEntries.length} 个有效`);
|
145 |
+
}
|
146 |
+
|
147 |
+
// 删除指定cookie
|
148 |
+
async function removeCookie() {
|
149 |
+
if (!cookieManager.initialized || cookieManager.cookieEntries.length === 0) {
|
150 |
+
logger.warning('没有可用的cookie,请先加载或添加cookie');
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
// 先列出所有cookie
|
155 |
+
await listCookies();
|
156 |
+
|
157 |
+
return new Promise((resolve) => {
|
158 |
+
rl.question(chalk.yellow('请输入要删除的cookie编号: '), (input) => {
|
159 |
+
const index = parseInt(input) - 1;
|
160 |
+
|
161 |
+
if (isNaN(index) || index < 0 || index >= cookieManager.cookieEntries.length) {
|
162 |
+
logger.error('无效的编号');
|
163 |
+
resolve();
|
164 |
+
return;
|
165 |
+
}
|
166 |
+
|
167 |
+
const removed = cookieManager.cookieEntries.splice(index, 1)[0];
|
168 |
+
logger.success(`已删除编号 ${index + 1} 的cookie (用户ID: ${removed.userId.substring(0, 8)}...)`);
|
169 |
+
|
170 |
+
// 重置当前索引
|
171 |
+
if (cookieManager.cookieEntries.length > 0) {
|
172 |
+
cookieManager.currentIndex = 0;
|
173 |
+
}
|
174 |
+
|
175 |
+
resolve();
|
176 |
+
});
|
177 |
+
});
|
178 |
+
}
|
179 |
+
|
180 |
+
// 保存cookie到文件
|
181 |
+
async function saveCookies() {
|
182 |
+
if (!cookieManager.initialized || cookieManager.cookieEntries.length === 0) {
|
183 |
+
logger.warning('没有可用的cookie,请先加载或添加cookie');
|
184 |
+
return;
|
185 |
+
}
|
186 |
+
|
187 |
+
return new Promise((resolve) => {
|
188 |
+
rl.question(chalk.yellow(`请输入保存文件路径 (默认: ${DEFAULT_COOKIE_FILE}): `), (filePath) => {
|
189 |
+
const path = filePath.trim() || DEFAULT_COOKIE_FILE;
|
190 |
+
|
191 |
+
rl.question(chalk.yellow('是否只保存有效的cookie? (y/n, 默认: y): '), (onlyValidInput) => {
|
192 |
+
const onlyValid = onlyValidInput.toLowerCase() !== 'n';
|
193 |
+
|
194 |
+
const success = cookieManager.saveToFile(path, onlyValid);
|
195 |
+
if (success) {
|
196 |
+
logger.success(`Cookie已保存到文件: ${path}`);
|
197 |
+
isSaveCookie = true;
|
198 |
+
}
|
199 |
+
|
200 |
+
resolve();
|
201 |
+
});
|
202 |
+
});
|
203 |
+
});
|
204 |
+
}
|
205 |
+
|
206 |
+
// 从文件加载cookie
|
207 |
+
async function loadCookies() {
|
208 |
+
return new Promise((resolve) => {
|
209 |
+
rl.question(chalk.yellow(`请输入cookie文件路径 (默认: ${DEFAULT_COOKIE_FILE}): `), async (filePath) => {
|
210 |
+
const path = filePath.trim() || DEFAULT_COOKIE_FILE;
|
211 |
+
|
212 |
+
logger.info(`正在从文件加载cookie: ${path}`);
|
213 |
+
const success = await cookieManager.loadFromFile(path);
|
214 |
+
|
215 |
+
if (success) {
|
216 |
+
logger.success(`成功从文件加载cookie,共 ${cookieManager.getValidCount()} 个有效cookie`);
|
217 |
+
} else {
|
218 |
+
logger.error(`从文件加载cookie失败`);
|
219 |
+
}
|
220 |
+
|
221 |
+
resolve();
|
222 |
+
});
|
223 |
+
});
|
224 |
+
}
|
225 |
+
|
226 |
+
// 主函数
|
227 |
+
async function main() {
|
228 |
+
// 显示欢迎信息
|
229 |
+
console.log(chalk.cyan('\nNotion Cookie 管理工具'));
|
230 |
+
console.log(chalk.cyan('====================\n'));
|
231 |
+
|
232 |
+
// 检查是否有环境变量中的cookie
|
233 |
+
const envCookie = process.env.NOTION_COOKIE;
|
234 |
+
if (envCookie) {
|
235 |
+
logger.info('检测到环境变量中的NOTION_COOKIE,正在初始化...');
|
236 |
+
await cookieManager.initialize(envCookie);
|
237 |
+
}
|
238 |
+
|
239 |
+
// 检查是否有环境变量中的cookie文件
|
240 |
+
const envCookieFile = process.env.COOKIE_FILE;
|
241 |
+
if (envCookieFile && !cookieManager.initialized) {
|
242 |
+
logger.info(`检测到环境变量中的COOKIE_FILE: ${envCookieFile},正在加载...`);
|
243 |
+
await cookieManager.loadFromFile(envCookieFile);
|
244 |
+
}
|
245 |
+
|
246 |
+
// 如果没有cookie,检查默认文件
|
247 |
+
if (!cookieManager.initialized && fs.existsSync(DEFAULT_COOKIE_FILE)) {
|
248 |
+
logger.info(`检测到默认cookie文件: ${DEFAULT_COOKIE_FILE},正在加载...`);
|
249 |
+
await cookieManager.loadFromFile(DEFAULT_COOKIE_FILE);
|
250 |
+
}
|
251 |
+
|
252 |
+
showHelp();
|
253 |
+
|
254 |
+
// 命令循环
|
255 |
+
while (true) {
|
256 |
+
const command = await new Promise((resolve) => {
|
257 |
+
rl.question(chalk.green('> '), (cmd) => {
|
258 |
+
resolve(cmd.trim().toLowerCase());
|
259 |
+
});
|
260 |
+
});
|
261 |
+
|
262 |
+
switch (command) {
|
263 |
+
case 'help':
|
264 |
+
showHelp();
|
265 |
+
break;
|
266 |
+
case 'list':
|
267 |
+
await listCookies();
|
268 |
+
break;
|
269 |
+
case 'add':
|
270 |
+
await addCookie();
|
271 |
+
break;
|
272 |
+
case 'validate':
|
273 |
+
await validateCookies();
|
274 |
+
break;
|
275 |
+
case 'remove':
|
276 |
+
await removeCookie();
|
277 |
+
break;
|
278 |
+
case 'save':
|
279 |
+
await saveCookies();
|
280 |
+
break;
|
281 |
+
case 'load':
|
282 |
+
await loadCookies();
|
283 |
+
break;
|
284 |
+
case 'exit':
|
285 |
+
case 'quit':
|
286 |
+
case 'q':
|
287 |
+
logger.info('感谢使用,再见!');
|
288 |
+
rl.close();
|
289 |
+
process.exit(0);
|
290 |
+
default:
|
291 |
+
logger.error(`未知命令: ${command}`);
|
292 |
+
logger.info('输入 "help" 查看可用命令');
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
// 启动程序
|
298 |
+
main().catch((error) => {
|
299 |
+
logger.error(`程序出错: ${error.message}`);
|
300 |
+
process.exit(1);
|
301 |
+
});
|
src/lightweight-client-express.js
ADDED
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express from 'express';
|
2 |
+
import dotenv from 'dotenv';
|
3 |
+
import { randomUUID } from 'crypto';
|
4 |
+
import { fileURLToPath } from 'url';
|
5 |
+
import { dirname, join } from 'path';
|
6 |
+
import chalk from 'chalk';
|
7 |
+
import {
|
8 |
+
ChatMessage, ChatCompletionRequest, Choice, ChoiceDelta, ChatCompletionChunk
|
9 |
+
} from './models.js';
|
10 |
+
import {
|
11 |
+
initialize,
|
12 |
+
streamNotionResponse,
|
13 |
+
buildNotionRequest,
|
14 |
+
INITIALIZED_SUCCESSFULLY
|
15 |
+
} from './lightweight-client.js';
|
16 |
+
import { proxyPool } from './ProxyPool.js';
|
17 |
+
import { cookieManager } from './CookieManager.js';
|
18 |
+
|
19 |
+
// 获取当前文件的目录路径
|
20 |
+
const __filename = fileURLToPath(import.meta.url);
|
21 |
+
const __dirname = dirname(__filename);
|
22 |
+
|
23 |
+
// 加载环境变量
|
24 |
+
dotenv.config({ path: join(dirname(__dirname), '.env') });
|
25 |
+
|
26 |
+
// 活跃流管理器 - 用于跟踪和管理当前活跃的请求流
|
27 |
+
const activeStreams = new Map();
|
28 |
+
|
29 |
+
// 日志配置
|
30 |
+
const logger = {
|
31 |
+
info: (message) => console.log(chalk.blue(`[info] ${message}`)),
|
32 |
+
error: (message) => console.error(chalk.red(`[error] ${message}`)),
|
33 |
+
warning: (message) => console.warn(chalk.yellow(`[warn] ${message}`)),
|
34 |
+
success: (message) => console.log(chalk.green(`[success] ${message}`)),
|
35 |
+
request: (method, path, status, time) => {
|
36 |
+
const statusColor = status >= 500 ? chalk.red :
|
37 |
+
status >= 400 ? chalk.yellow :
|
38 |
+
status >= 300 ? chalk.cyan :
|
39 |
+
status >= 200 ? chalk.green : chalk.white;
|
40 |
+
console.log(`${chalk.magenta(`[${method}]`)} - ${path} ${statusColor(status)} ${chalk.gray(`${time}ms`)}`);
|
41 |
+
}
|
42 |
+
};
|
43 |
+
|
44 |
+
// 认证配置
|
45 |
+
const EXPECTED_TOKEN = process.env.PROXY_AUTH_TOKEN || "default_token";
|
46 |
+
|
47 |
+
// 创建Express应用
|
48 |
+
const app = express();
|
49 |
+
app.use(express.json({ limit: '50mb' }));
|
50 |
+
app.use(express.urlencoded({ extended: true, limit: '50mb' }));
|
51 |
+
|
52 |
+
// 请求日志中间件
|
53 |
+
app.use((req, res, next) => {
|
54 |
+
const start = Date.now();
|
55 |
+
|
56 |
+
// 保存原始的 end 方法
|
57 |
+
const originalEnd = res.end;
|
58 |
+
|
59 |
+
// 重写 end 方法以记录请求完成时间
|
60 |
+
res.end = function(...args) {
|
61 |
+
const duration = Date.now() - start;
|
62 |
+
logger.request(req.method, req.path, res.statusCode, duration);
|
63 |
+
return originalEnd.apply(this, args);
|
64 |
+
};
|
65 |
+
|
66 |
+
next();
|
67 |
+
});
|
68 |
+
|
69 |
+
// 认证中间件
|
70 |
+
function authenticate(req, res, next) {
|
71 |
+
const authHeader = req.headers.authorization;
|
72 |
+
|
73 |
+
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
74 |
+
return res.status(401).json({
|
75 |
+
error: {
|
76 |
+
message: "Authentication required. Please provide a valid Bearer token.",
|
77 |
+
type: "authentication_error"
|
78 |
+
}
|
79 |
+
});
|
80 |
+
}
|
81 |
+
|
82 |
+
const token = authHeader.split(' ')[1];
|
83 |
+
|
84 |
+
if (token !== EXPECTED_TOKEN) {
|
85 |
+
return res.status(401).json({
|
86 |
+
error: {
|
87 |
+
message: "Invalid authentication credentials",
|
88 |
+
type: "authentication_error"
|
89 |
+
}
|
90 |
+
});
|
91 |
+
}
|
92 |
+
|
93 |
+
next();
|
94 |
+
}
|
95 |
+
|
96 |
+
// 流管理函数
|
97 |
+
function manageStream(clientId, stream) {
|
98 |
+
// 如果该客户端已有活跃流,先关闭它
|
99 |
+
if (activeStreams.has(clientId)) {
|
100 |
+
try {
|
101 |
+
const oldStream = activeStreams.get(clientId);
|
102 |
+
logger.info(`关闭客户端 ${clientId} 的旧流`);
|
103 |
+
oldStream.end();
|
104 |
+
} catch (error) {
|
105 |
+
logger.error(`关闭旧流时出错: ${error.message}`);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
// 注册新流
|
110 |
+
activeStreams.set(clientId, stream);
|
111 |
+
|
112 |
+
// 当流结束时从管理器中移除
|
113 |
+
stream.on('end', () => {
|
114 |
+
if (activeStreams.get(clientId) === stream) {
|
115 |
+
activeStreams.delete(clientId);
|
116 |
+
//logger.info(`客户端 ${clientId} 的流已结束并移除`);
|
117 |
+
}
|
118 |
+
});
|
119 |
+
|
120 |
+
stream.on('error', (error) => {
|
121 |
+
logger.error(`流错误: ${error.message}`);
|
122 |
+
if (activeStreams.get(clientId) === stream) {
|
123 |
+
activeStreams.delete(clientId);
|
124 |
+
}
|
125 |
+
});
|
126 |
+
|
127 |
+
return stream;
|
128 |
+
}
|
129 |
+
|
130 |
+
// API路由
|
131 |
+
|
132 |
+
// 获取模型列表
|
133 |
+
app.get('/v1/models', authenticate, (req, res) => {
|
134 |
+
// 返回可用模型列表
|
135 |
+
const modelList = {
|
136 |
+
data: [
|
137 |
+
{ id: "openai-gpt-4.1" },
|
138 |
+
{ id: "anthropic-opus-4" },
|
139 |
+
{ id: "anthropic-sonnet-4" },
|
140 |
+
{ id: "anthropic-sonnet-3.x-stable" }
|
141 |
+
]
|
142 |
+
};
|
143 |
+
|
144 |
+
res.json(modelList);
|
145 |
+
});
|
146 |
+
|
147 |
+
// 聊天完成端点
|
148 |
+
app.post('/v1/chat/completions', authenticate, async (req, res) => {
|
149 |
+
try {
|
150 |
+
// 生成或获取客户端ID
|
151 |
+
const clientId = req.headers['x-client-id'] || randomUUID();
|
152 |
+
|
153 |
+
// 检查是否成功初始化
|
154 |
+
if (!INITIALIZED_SUCCESSFULLY) {
|
155 |
+
return res.status(500).json({
|
156 |
+
error: {
|
157 |
+
message: "系统未成功初始化。请检查您的NOTION_COOKIE是否有效。",
|
158 |
+
type: "server_error"
|
159 |
+
}
|
160 |
+
});
|
161 |
+
}
|
162 |
+
|
163 |
+
// 检查是否有可用的cookie
|
164 |
+
if (cookieManager.getValidCount() === 0) {
|
165 |
+
return res.status(500).json({
|
166 |
+
error: {
|
167 |
+
message: "没有可用的有效cookie。请检查您的NOTION_COOKIE配置。",
|
168 |
+
type: "server_error"
|
169 |
+
}
|
170 |
+
});
|
171 |
+
}
|
172 |
+
|
173 |
+
// 验证请求数据
|
174 |
+
const requestData = req.body;
|
175 |
+
|
176 |
+
if (!requestData.messages || !Array.isArray(requestData.messages) || requestData.messages.length === 0) {
|
177 |
+
return res.status(400).json({
|
178 |
+
error: {
|
179 |
+
message: "Invalid request: 'messages' field must be a non-empty array.",
|
180 |
+
type: "invalid_request_error"
|
181 |
+
}
|
182 |
+
});
|
183 |
+
}
|
184 |
+
|
185 |
+
// 构建Notion请求
|
186 |
+
const notionRequestBody = buildNotionRequest(requestData);
|
187 |
+
|
188 |
+
// 处理流式响应
|
189 |
+
if (requestData.stream) {
|
190 |
+
res.setHeader('Content-Type', 'text/event-stream');
|
191 |
+
res.setHeader('Cache-Control', 'no-cache');
|
192 |
+
res.setHeader('Connection', 'keep-alive');
|
193 |
+
|
194 |
+
logger.info(`开始流式响应`);
|
195 |
+
const stream = await streamNotionResponse(notionRequestBody);
|
196 |
+
|
197 |
+
// 管理流
|
198 |
+
manageStream(clientId, stream);
|
199 |
+
|
200 |
+
stream.pipe(res);
|
201 |
+
|
202 |
+
// 处理客户端断开连接
|
203 |
+
req.on('close', () => {
|
204 |
+
logger.info(`客户端 ${clientId} 断开连接`);
|
205 |
+
if (activeStreams.has(clientId)) {
|
206 |
+
try {
|
207 |
+
activeStreams.get(clientId).end();
|
208 |
+
activeStreams.delete(clientId);
|
209 |
+
} catch (error) {
|
210 |
+
logger.error(`关闭流时出错: ${error.message}`);
|
211 |
+
}
|
212 |
+
}
|
213 |
+
});
|
214 |
+
} else {
|
215 |
+
// 非流式响应
|
216 |
+
// 创建一个内部流来收集完整响应
|
217 |
+
logger.info(`开始非流式响应`);
|
218 |
+
const chunks = [];
|
219 |
+
const stream = await streamNotionResponse(notionRequestBody);
|
220 |
+
|
221 |
+
// 管理流
|
222 |
+
manageStream(clientId, stream);
|
223 |
+
|
224 |
+
return new Promise((resolve, reject) => {
|
225 |
+
stream.on('data', (chunk) => {
|
226 |
+
const chunkStr = chunk.toString();
|
227 |
+
if (chunkStr.startsWith('data: ') && !chunkStr.includes('[DONE]')) {
|
228 |
+
try {
|
229 |
+
const dataJson = chunkStr.substring(6).trim();
|
230 |
+
if (dataJson) {
|
231 |
+
const chunkData = JSON.parse(dataJson);
|
232 |
+
if (chunkData.choices && chunkData.choices[0].delta && chunkData.choices[0].delta.content) {
|
233 |
+
chunks.push(chunkData.choices[0].delta.content);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
} catch (error) {
|
237 |
+
logger.error(`解析非流式响应块时出错: ${error}`);
|
238 |
+
}
|
239 |
+
}
|
240 |
+
});
|
241 |
+
|
242 |
+
stream.on('end', () => {
|
243 |
+
const fullResponse = {
|
244 |
+
id: `chatcmpl-${randomUUID()}`,
|
245 |
+
object: "chat.completion",
|
246 |
+
created: Math.floor(Date.now() / 1000),
|
247 |
+
model: requestData.model,
|
248 |
+
choices: [
|
249 |
+
{
|
250 |
+
index: 0,
|
251 |
+
message: {
|
252 |
+
role: "assistant",
|
253 |
+
content: chunks.join('')
|
254 |
+
},
|
255 |
+
finish_reason: "stop"
|
256 |
+
}
|
257 |
+
],
|
258 |
+
usage: {
|
259 |
+
prompt_tokens: null,
|
260 |
+
completion_tokens: null,
|
261 |
+
total_tokens: null
|
262 |
+
}
|
263 |
+
};
|
264 |
+
|
265 |
+
res.json(fullResponse);
|
266 |
+
resolve();
|
267 |
+
});
|
268 |
+
|
269 |
+
stream.on('error', (error) => {
|
270 |
+
logger.error(`非流式响应出错: ${error}`);
|
271 |
+
reject(error);
|
272 |
+
});
|
273 |
+
|
274 |
+
// 处理客户端断开连接
|
275 |
+
req.on('close', () => {
|
276 |
+
logger.info(`客户端 ${clientId} 断开连接(非流式)`);
|
277 |
+
if (activeStreams.has(clientId)) {
|
278 |
+
try {
|
279 |
+
activeStreams.get(clientId).end();
|
280 |
+
activeStreams.delete(clientId);
|
281 |
+
} catch (error) {
|
282 |
+
logger.error(`关闭流时出错: ${error.message}`);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
});
|
286 |
+
});
|
287 |
+
}
|
288 |
+
} catch (error) {
|
289 |
+
logger.error(`聊天完成端点错误: ${error}`);
|
290 |
+
res.status(500).json({
|
291 |
+
error: {
|
292 |
+
message: `Internal server error: ${error.message}`,
|
293 |
+
type: "server_error"
|
294 |
+
}
|
295 |
+
});
|
296 |
+
}
|
297 |
+
});
|
298 |
+
|
299 |
+
// 健康检查端点
|
300 |
+
app.get('/health', (req, res) => {
|
301 |
+
res.json({
|
302 |
+
status: 'ok',
|
303 |
+
timestamp: new Date().toISOString(),
|
304 |
+
initialized: INITIALIZED_SUCCESSFULLY,
|
305 |
+
valid_cookies: cookieManager.getValidCount(),
|
306 |
+
active_streams: activeStreams.size
|
307 |
+
});
|
308 |
+
});
|
309 |
+
|
310 |
+
// Cookie状态查询端点
|
311 |
+
app.get('/cookies/status', authenticate, (req, res) => {
|
312 |
+
res.json({
|
313 |
+
total_cookies: cookieManager.getValidCount(),
|
314 |
+
cookies: cookieManager.getStatus()
|
315 |
+
});
|
316 |
+
});
|
317 |
+
|
318 |
+
// 启动服务器
|
319 |
+
const PORT = process.env.PORT || 7860;
|
320 |
+
|
321 |
+
// 设置代理池日志级别为warn,减少详细日志输出
|
322 |
+
proxyPool.logLevel = 'warn';
|
323 |
+
|
324 |
+
// 初始化并启动服务器
|
325 |
+
initialize().then(() => {
|
326 |
+
app.listen(PORT, () => {
|
327 |
+
logger.info(`服务已启动 - 端口: ${PORT}`);
|
328 |
+
logger.info(`访问地址: http://localhost:${PORT}`);
|
329 |
+
|
330 |
+
if (INITIALIZED_SUCCESSFULLY) {
|
331 |
+
logger.success(`系统初始化状态: ✅`);
|
332 |
+
logger.success(`可用cookie数量: ${cookieManager.getValidCount()}`);
|
333 |
+
} else {
|
334 |
+
logger.warning(`系统初始化状态: ❌`);
|
335 |
+
logger.warning(`警告: 系统未成功初始化,API调��将无法正常工作`);
|
336 |
+
logger.warning(`请检查NOTION_COOKIE配置是否有效`);
|
337 |
+
}
|
338 |
+
});
|
339 |
+
}).catch((error) => {
|
340 |
+
logger.error(`初始化失败: ${error}`);
|
341 |
+
});
|
src/lightweight-client.js
ADDED
@@ -0,0 +1,856 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fetch from 'node-fetch';
|
2 |
+
import { JSDOM } from 'jsdom';
|
3 |
+
import dotenv from 'dotenv';
|
4 |
+
import { randomUUID } from 'crypto';
|
5 |
+
import { fileURLToPath } from 'url';
|
6 |
+
import { dirname, join } from 'path';
|
7 |
+
import { PassThrough } from 'stream';
|
8 |
+
import chalk from 'chalk';
|
9 |
+
import {
|
10 |
+
NotionTranscriptConfigValue,
|
11 |
+
NotionTranscriptContextValue, NotionTranscriptItem, NotionDebugOverrides,
|
12 |
+
NotionRequestBody, ChoiceDelta, Choice, ChatCompletionChunk, NotionTranscriptItemByuser
|
13 |
+
} from './models.js';
|
14 |
+
import { proxyPool } from './ProxyPool.js';
|
15 |
+
import { proxyServer } from './ProxyServer.js';
|
16 |
+
import { cookieManager } from './CookieManager.js';
|
17 |
+
|
18 |
+
// 获取当前文件的目录路径
|
19 |
+
const __filename = fileURLToPath(import.meta.url);
|
20 |
+
const __dirname = dirname(__filename);
|
21 |
+
|
22 |
+
// 加载环境变量
|
23 |
+
dotenv.config({ path: join(dirname(__dirname), '.env') });
|
24 |
+
|
25 |
+
// 日志配置
|
26 |
+
const logger = {
|
27 |
+
info: (message) => console.log(chalk.blue(`[info] ${message}`)),
|
28 |
+
error: (message) => console.error(chalk.red(`[error] ${message}`)),
|
29 |
+
warning: (message) => console.warn(chalk.yellow(`[warn] ${message}`)),
|
30 |
+
success: (message) => console.log(chalk.green(`[success] ${message}`)),
|
31 |
+
};
|
32 |
+
|
33 |
+
// 配置
|
34 |
+
const NOTION_API_URL = "https://www.notion.so/api/v3/runInferenceTranscript";
|
35 |
+
// 这些变量将由cookieManager动态提供
|
36 |
+
let currentCookieData = null;
|
37 |
+
const USE_NATIVE_PROXY_POOL = process.env.USE_NATIVE_PROXY_POOL === 'true';
|
38 |
+
const ENABLE_PROXY_SERVER = process.env.ENABLE_PROXY_SERVER === 'true';
|
39 |
+
let proxy = null;
|
40 |
+
|
41 |
+
// 代理配置
|
42 |
+
const PROXY_URL = process.env.PROXY_URL || "";
|
43 |
+
|
44 |
+
// 标记是否成功初始化
|
45 |
+
let INITIALIZED_SUCCESSFULLY = false;
|
46 |
+
|
47 |
+
// 注册进程退出事件,确保代理服务器在程序退出时关闭
|
48 |
+
process.on('exit', () => {
|
49 |
+
try {
|
50 |
+
if (proxyServer) {
|
51 |
+
proxyServer.stop();
|
52 |
+
}
|
53 |
+
} catch (error) {
|
54 |
+
logger.error(`程序退出时关闭代理服务器出错: ${error.message}`);
|
55 |
+
}
|
56 |
+
});
|
57 |
+
|
58 |
+
// 捕获意外退出信号
|
59 |
+
['SIGINT', 'SIGTERM', 'SIGQUIT'].forEach(signal => {
|
60 |
+
process.on(signal, () => {
|
61 |
+
logger.info(`收到${signal}信号,正在关闭代理服务器...`);
|
62 |
+
try {
|
63 |
+
if (proxyServer) {
|
64 |
+
proxyServer.stop();
|
65 |
+
}
|
66 |
+
} catch (error) {
|
67 |
+
logger.error(`关闭代理服务器出错: ${error.message}`);
|
68 |
+
}
|
69 |
+
process.exit(0);
|
70 |
+
});
|
71 |
+
});
|
72 |
+
|
73 |
+
// 构建Notion请求
|
74 |
+
function buildNotionRequest(requestData) {
|
75 |
+
// 确保我们有当前的cookie数据
|
76 |
+
if (!currentCookieData) {
|
77 |
+
currentCookieData = cookieManager.getNext();
|
78 |
+
if (!currentCookieData) {
|
79 |
+
throw new Error('没有可用的cookie');
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
// 当前时间
|
84 |
+
const now = new Date();
|
85 |
+
// 格式化为ISO字符串,确保包含毫秒和时区
|
86 |
+
const isoString = now.toISOString();
|
87 |
+
|
88 |
+
// 生成随机名称,类似于Python版本
|
89 |
+
const randomWords = ["Project", "Workspace", "Team", "Studio", "Lab", "Hub", "Zone", "Space"];
|
90 |
+
const userName = `User${Math.floor(Math.random() * 900) + 100}`; // 生成100-999之间的随机数
|
91 |
+
const spaceName = `${randomWords[Math.floor(Math.random() * randomWords.length)]} ${Math.floor(Math.random() * 99) + 1}`;
|
92 |
+
|
93 |
+
// 创建transcript数组
|
94 |
+
const transcript = [];
|
95 |
+
|
96 |
+
// 添加配置项
|
97 |
+
if(requestData.model === 'anthropic-sonnet-3.x-stable'){
|
98 |
+
transcript.push(new NotionTranscriptItem({
|
99 |
+
type: "config",
|
100 |
+
value: new NotionTranscriptConfigValue({
|
101 |
+
})
|
102 |
+
}));
|
103 |
+
}else{
|
104 |
+
transcript.push(new NotionTranscriptItem({
|
105 |
+
type: "config",
|
106 |
+
value: new NotionTranscriptConfigValue({
|
107 |
+
model: requestData.model
|
108 |
+
})
|
109 |
+
}));
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
// 添加上下文项
|
114 |
+
transcript.push(new NotionTranscriptItem({
|
115 |
+
type: "context",
|
116 |
+
value: new NotionTranscriptContextValue({
|
117 |
+
userId: currentCookieData.userId,
|
118 |
+
spaceId: currentCookieData.spaceId,
|
119 |
+
surface: "home_module",
|
120 |
+
timezone: "America/Los_Angeles",
|
121 |
+
userName: userName,
|
122 |
+
spaceName: spaceName,
|
123 |
+
spaceViewId: randomUUID(),
|
124 |
+
currentDatetime: isoString
|
125 |
+
})
|
126 |
+
}));
|
127 |
+
|
128 |
+
// 添加agent-integration项
|
129 |
+
transcript.push(new NotionTranscriptItem({
|
130 |
+
type: "agent-integration"
|
131 |
+
}));
|
132 |
+
|
133 |
+
// 添加消息
|
134 |
+
for (const message of requestData.messages) {
|
135 |
+
// 处理消息内容,确保格式一致
|
136 |
+
let content = message.content;
|
137 |
+
|
138 |
+
// 处理内容为数组的情况
|
139 |
+
if (Array.isArray(content)) {
|
140 |
+
let textContent = "";
|
141 |
+
for (const part of content) {
|
142 |
+
if (part && typeof part === 'object' && part.type === 'text') {
|
143 |
+
if (typeof part.text === 'string') {
|
144 |
+
textContent += part.text;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
content = textContent || ""; // 使用提取的文本或空字符串
|
149 |
+
} else if (typeof content !== 'string') {
|
150 |
+
content = ""; // 如果不是字符串或数组,则默认为空字符串
|
151 |
+
}
|
152 |
+
|
153 |
+
if (message.role === "system") {
|
154 |
+
// 系统消息作为用户消息添加
|
155 |
+
transcript.push(new NotionTranscriptItemByuser({
|
156 |
+
type: "user",
|
157 |
+
value: [[content]],
|
158 |
+
userId: currentCookieData.userId,
|
159 |
+
createdAt: message.createdAt || isoString
|
160 |
+
}));
|
161 |
+
} else if (message.role === "user") {
|
162 |
+
// 用户消息
|
163 |
+
transcript.push(new NotionTranscriptItemByuser({
|
164 |
+
type: "user",
|
165 |
+
value: [[content]],
|
166 |
+
userId: currentCookieData.userId,
|
167 |
+
createdAt: message.createdAt || isoString
|
168 |
+
}));
|
169 |
+
} else if (message.role === "assistant") {
|
170 |
+
// 助手消息
|
171 |
+
transcript.push(new NotionTranscriptItem({
|
172 |
+
type: "markdown-chat",
|
173 |
+
value: content,
|
174 |
+
traceId: message.traceId || randomUUID(),
|
175 |
+
createdAt: message.createdAt || isoString
|
176 |
+
}));
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
// 创建请求体
|
181 |
+
return new NotionRequestBody({
|
182 |
+
spaceId: currentCookieData.spaceId,
|
183 |
+
transcript: transcript,
|
184 |
+
createThread: true,
|
185 |
+
traceId: randomUUID(),
|
186 |
+
debugOverrides: new NotionDebugOverrides({
|
187 |
+
cachedInferences: {},
|
188 |
+
annotationInferences: {},
|
189 |
+
emitInferences: false
|
190 |
+
}),
|
191 |
+
generateTitle: false,
|
192 |
+
saveAllThreadOperations: false
|
193 |
+
});
|
194 |
+
}
|
195 |
+
|
196 |
+
// 流式处理Notion响应
|
197 |
+
async function streamNotionResponse(notionRequestBody) {
|
198 |
+
// 确保我们有当前的cookie数据
|
199 |
+
if (!currentCookieData) {
|
200 |
+
currentCookieData = cookieManager.getNext();
|
201 |
+
if (!currentCookieData) {
|
202 |
+
throw new Error('没有可用的cookie');
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
// 创建流
|
207 |
+
const stream = new PassThrough();
|
208 |
+
|
209 |
+
// 标记流状态
|
210 |
+
let streamClosed = false;
|
211 |
+
|
212 |
+
// 重写stream.end方法,确保安全关闭
|
213 |
+
const originalEnd = stream.end;
|
214 |
+
stream.end = function(...args) {
|
215 |
+
if (streamClosed) return; // 避免重复关闭
|
216 |
+
streamClosed = true;
|
217 |
+
return originalEnd.apply(this, args);
|
218 |
+
};
|
219 |
+
|
220 |
+
// 添加初始数据,确保连接建立
|
221 |
+
stream.write(':\n\n'); // 发送一个空注释行,保持连接活跃
|
222 |
+
|
223 |
+
// 设置HTTP头模板
|
224 |
+
const headers = {
|
225 |
+
'Content-Type': 'application/json',
|
226 |
+
'accept': 'application/x-ndjson',
|
227 |
+
'accept-language': 'en-US,en;q=0.9',
|
228 |
+
'notion-audit-log-platform': 'web',
|
229 |
+
'notion-client-version': '23.13.0.3686',
|
230 |
+
'origin': 'https://www.notion.so',
|
231 |
+
'referer': 'https://www.notion.so/chat',
|
232 |
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36',
|
233 |
+
'x-notion-active-user-header': currentCookieData.userId,
|
234 |
+
'x-notion-space-id': currentCookieData.spaceId
|
235 |
+
};
|
236 |
+
|
237 |
+
// 设置超时处理,确保流不会无限等待
|
238 |
+
const timeoutId = setTimeout(() => {
|
239 |
+
if (streamClosed) return;
|
240 |
+
|
241 |
+
logger.warning(`请求超时,30秒内未收到响应`);
|
242 |
+
try {
|
243 |
+
// 发送结束消息
|
244 |
+
const endChunk = new ChatCompletionChunk({
|
245 |
+
choices: [
|
246 |
+
new Choice({
|
247 |
+
delta: new ChoiceDelta({ content: "请求超时,未收到Notion响应。" }),
|
248 |
+
finish_reason: "timeout"
|
249 |
+
})
|
250 |
+
]
|
251 |
+
});
|
252 |
+
stream.write(`data: ${JSON.stringify(endChunk)}\n\n`);
|
253 |
+
stream.write('data: [DONE]\n\n');
|
254 |
+
stream.end();
|
255 |
+
} catch (error) {
|
256 |
+
logger.error(`发送超时消息时出错: ${error}`);
|
257 |
+
if (!streamClosed) stream.end();
|
258 |
+
}
|
259 |
+
}, 30000); // 30秒超时
|
260 |
+
|
261 |
+
// 启动fetch处理
|
262 |
+
fetchNotionResponse(
|
263 |
+
stream,
|
264 |
+
notionRequestBody,
|
265 |
+
headers,
|
266 |
+
NOTION_API_URL,
|
267 |
+
currentCookieData.cookie,
|
268 |
+
timeoutId
|
269 |
+
).catch((error) => {
|
270 |
+
if (streamClosed) return;
|
271 |
+
|
272 |
+
logger.error(`流处理出错: ${error}`);
|
273 |
+
clearTimeout(timeoutId); // 清除超时计时器
|
274 |
+
|
275 |
+
try {
|
276 |
+
// 发送错误消息
|
277 |
+
const errorChunk = new ChatCompletionChunk({
|
278 |
+
choices: [
|
279 |
+
new Choice({
|
280 |
+
delta: new ChoiceDelta({ content: `处理请求时出错: ${error.message}` }),
|
281 |
+
finish_reason: "error"
|
282 |
+
})
|
283 |
+
]
|
284 |
+
});
|
285 |
+
stream.write(`data: ${JSON.stringify(errorChunk)}\n\n`);
|
286 |
+
stream.write('data: [DONE]\n\n');
|
287 |
+
} catch (e) {
|
288 |
+
logger.error(`发送错误消息时出错: ${e}`);
|
289 |
+
} finally {
|
290 |
+
if (!streamClosed) stream.end();
|
291 |
+
}
|
292 |
+
});
|
293 |
+
|
294 |
+
return stream;
|
295 |
+
}
|
296 |
+
|
297 |
+
// 使用fetch调用Notion API并处理流式响应
|
298 |
+
async function fetchNotionResponse(chunkQueue, notionRequestBody, headers, notionApiUrl, notionCookie, timeoutId) {
|
299 |
+
let responseReceived = false;
|
300 |
+
let dom = null;
|
301 |
+
|
302 |
+
// 检查流是否已关闭的辅助函数
|
303 |
+
const isStreamClosed = () => {
|
304 |
+
return chunkQueue.destroyed || (typeof chunkQueue.closed === 'boolean' && chunkQueue.closed);
|
305 |
+
};
|
306 |
+
|
307 |
+
// 安全写入函数,确保只向开启的流写入数据
|
308 |
+
const safeWrite = (data) => {
|
309 |
+
if (!isStreamClosed()) {
|
310 |
+
try {
|
311 |
+
return chunkQueue.write(data);
|
312 |
+
} catch (error) {
|
313 |
+
logger.error(`流写入错误: ${error.message}`);
|
314 |
+
return false;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
return false;
|
318 |
+
};
|
319 |
+
|
320 |
+
try {
|
321 |
+
// 创建JSDOM实例模拟浏览器环境
|
322 |
+
dom = new JSDOM("", {
|
323 |
+
url: "https://www.notion.so",
|
324 |
+
referrer: "https://www.notion.so/chat",
|
325 |
+
contentType: "text/html",
|
326 |
+
includeNodeLocations: true,
|
327 |
+
storageQuota: 10000000,
|
328 |
+
pretendToBeVisual: true,
|
329 |
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"
|
330 |
+
});
|
331 |
+
|
332 |
+
// 设置全局对象
|
333 |
+
const { window } = dom;
|
334 |
+
|
335 |
+
// 使用更安全的方式设置全局对象
|
336 |
+
try {
|
337 |
+
if (!global.window) {
|
338 |
+
global.window = window;
|
339 |
+
}
|
340 |
+
|
341 |
+
if (!global.document) {
|
342 |
+
global.document = window.document;
|
343 |
+
}
|
344 |
+
|
345 |
+
// 安全地设置navigator
|
346 |
+
if (!global.navigator) {
|
347 |
+
try {
|
348 |
+
Object.defineProperty(global, 'navigator', {
|
349 |
+
value: window.navigator,
|
350 |
+
writable: true,
|
351 |
+
configurable: true
|
352 |
+
});
|
353 |
+
} catch (navError) {
|
354 |
+
logger.warning(`无法设置navigator: ${navError.message},继续执行`);
|
355 |
+
// 继续执行,不会中断流程
|
356 |
+
}
|
357 |
+
}
|
358 |
+
} catch (globalError) {
|
359 |
+
logger.warning(`设置全局对象时出错: ${globalError.message}`);
|
360 |
+
}
|
361 |
+
|
362 |
+
// 设置cookie
|
363 |
+
document.cookie = notionCookie;
|
364 |
+
|
365 |
+
// 创建fetch选项
|
366 |
+
const fetchOptions = {
|
367 |
+
method: 'POST',
|
368 |
+
headers: {
|
369 |
+
...headers,
|
370 |
+
'user-agent': window.navigator.userAgent,
|
371 |
+
'Cookie': notionCookie
|
372 |
+
},
|
373 |
+
body: JSON.stringify(notionRequestBody),
|
374 |
+
};
|
375 |
+
|
376 |
+
// 添加代理配置(如果有)
|
377 |
+
if (USE_NATIVE_PROXY_POOL && ENABLE_PROXY_SERVER && !PROXY_URL) {
|
378 |
+
proxy = proxyPool.getProxy();
|
379 |
+
if (proxy !== null)
|
380 |
+
{
|
381 |
+
logger.info(`使用代理: ${proxy.full}`);
|
382 |
+
}
|
383 |
+
else{
|
384 |
+
logger.warning(`没有可用代理`);
|
385 |
+
}
|
386 |
+
} else if(USE_NATIVE_PROXY_POOL&&!PROXY_URL&&!ENABLE_PROXY_SERVER) {
|
387 |
+
const { HttpsProxyAgent } = await import('https-proxy-agent');
|
388 |
+
proxy = proxyPool.getProxy();
|
389 |
+
fetchOptions.agent = new HttpsProxyAgent(proxy.full);
|
390 |
+
logger.info(`使用代理: ${proxy.full}`);
|
391 |
+
}else if(!ENABLE_PROXY_SERVER && PROXY_URL){
|
392 |
+
const { HttpsProxyAgent } = await import('https-proxy-agent');
|
393 |
+
fetchOptions.agent = new HttpsProxyAgent(PROXY_URL);
|
394 |
+
logger.info(`使用代理: ${PROXY_URL}`);
|
395 |
+
}
|
396 |
+
let response = null;
|
397 |
+
// 发送请求
|
398 |
+
if (ENABLE_PROXY_SERVER && USE_NATIVE_PROXY_POOL){
|
399 |
+
response = await fetch('http://127.0.0.1:10655/proxy', {
|
400 |
+
method: 'POST',
|
401 |
+
body: JSON.stringify({
|
402 |
+
method: 'POST',
|
403 |
+
url: notionApiUrl,
|
404 |
+
headers: fetchOptions.headers,
|
405 |
+
body: fetchOptions.body,
|
406 |
+
stream:true,
|
407 |
+
proxy:proxy.full
|
408 |
+
}),
|
409 |
+
});
|
410 |
+
}
|
411 |
+
else if (ENABLE_PROXY_SERVER && !USE_NATIVE_PROXY_POOL && PROXY_URL){
|
412 |
+
response = await fetch('http://127.0.0.1:10655/proxy', {
|
413 |
+
method: 'POST',
|
414 |
+
body: JSON.stringify({
|
415 |
+
method: 'POST',
|
416 |
+
url: notionApiUrl,
|
417 |
+
headers: fetchOptions.headers,
|
418 |
+
body: fetchOptions.body,
|
419 |
+
proxy: PROXY_URL,
|
420 |
+
stream:true,
|
421 |
+
}),
|
422 |
+
});
|
423 |
+
}
|
424 |
+
else if(ENABLE_PROXY_SERVER && !USE_NATIVE_PROXY_POOL){
|
425 |
+
response = await fetch('http://127.0.0.1:10655/proxy', {
|
426 |
+
method: 'POST',
|
427 |
+
body: JSON.stringify({
|
428 |
+
method: 'POST',
|
429 |
+
url: notionApiUrl,
|
430 |
+
headers: fetchOptions.headers,
|
431 |
+
body: fetchOptions.body,
|
432 |
+
stream:true,
|
433 |
+
}),
|
434 |
+
});
|
435 |
+
}
|
436 |
+
else{
|
437 |
+
response = await fetch(notionApiUrl, fetchOptions);
|
438 |
+
}
|
439 |
+
|
440 |
+
// 检查是否收到401错误(未授权)
|
441 |
+
if (response.status === 401) {
|
442 |
+
logger.error(`收到401未授权错误,cookie可能已失效`);
|
443 |
+
// 标记当前cookie为无效
|
444 |
+
cookieManager.markAsInvalid(currentCookieData.userId);
|
445 |
+
// 尝试获取下一个cookie
|
446 |
+
currentCookieData = cookieManager.getNext();
|
447 |
+
|
448 |
+
if (!currentCookieData) {
|
449 |
+
throw new Error('所有cookie均已失效,无法继续请求');
|
450 |
+
}
|
451 |
+
|
452 |
+
// 使用新cookie重新构建请求体
|
453 |
+
const newRequestBody = buildNotionRequest({
|
454 |
+
model: notionRequestBody.transcript[0]?.value?.model || '',
|
455 |
+
messages: [] // 这里应该根据实际情况重构消息
|
456 |
+
});
|
457 |
+
|
458 |
+
// 使用新cookie重试请求
|
459 |
+
return fetchNotionResponse(
|
460 |
+
chunkQueue,
|
461 |
+
newRequestBody,
|
462 |
+
{
|
463 |
+
...headers,
|
464 |
+
'x-notion-active-user-header': currentCookieData.userId,
|
465 |
+
'x-notion-space-id': currentCookieData.spaceId
|
466 |
+
},
|
467 |
+
notionApiUrl,
|
468 |
+
currentCookieData.cookie,
|
469 |
+
timeoutId
|
470 |
+
);
|
471 |
+
}
|
472 |
+
|
473 |
+
if (!response.ok) {
|
474 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
475 |
+
}
|
476 |
+
|
477 |
+
// 处理流式响应
|
478 |
+
if (!response.body) {
|
479 |
+
throw new Error("Response body is null");
|
480 |
+
}
|
481 |
+
|
482 |
+
// 创建流读取器
|
483 |
+
const reader = response.body;
|
484 |
+
let buffer = '';
|
485 |
+
|
486 |
+
// 处理数据块
|
487 |
+
reader.on('data', (chunk) => {
|
488 |
+
// 检查流是否已关闭
|
489 |
+
if (isStreamClosed()) {
|
490 |
+
try {
|
491 |
+
reader.destroy();
|
492 |
+
} catch (error) {
|
493 |
+
logger.error(`销毁reader时出错: ${error.message}`);
|
494 |
+
}
|
495 |
+
return;
|
496 |
+
}
|
497 |
+
|
498 |
+
try {
|
499 |
+
// 标记已收到响应
|
500 |
+
if (!responseReceived) {
|
501 |
+
responseReceived = true;
|
502 |
+
logger.info(`已连接Notion API`);
|
503 |
+
clearTimeout(timeoutId); // 清除超时计时器
|
504 |
+
}
|
505 |
+
|
506 |
+
// 解码数据
|
507 |
+
const text = chunk.toString('utf8');
|
508 |
+
buffer += text;
|
509 |
+
|
510 |
+
// 按行分割并处理完整的JSON对象
|
511 |
+
const lines = buffer.split('\n');
|
512 |
+
buffer = lines.pop() || ''; // 保留最后一行(可能不完整)
|
513 |
+
|
514 |
+
for (const line of lines) {
|
515 |
+
if (!line.trim()) continue;
|
516 |
+
|
517 |
+
try {
|
518 |
+
const jsonData = JSON.parse(line);
|
519 |
+
|
520 |
+
// 提取内容
|
521 |
+
if (jsonData?.type === "markdown-chat" && typeof jsonData?.value === "string") {
|
522 |
+
const content = jsonData.value;
|
523 |
+
if (!content) continue;
|
524 |
+
|
525 |
+
// 创建OpenAI格式的块
|
526 |
+
const chunk = new ChatCompletionChunk({
|
527 |
+
choices: [
|
528 |
+
new Choice({
|
529 |
+
delta: new ChoiceDelta({ content }),
|
530 |
+
finish_reason: null
|
531 |
+
})
|
532 |
+
]
|
533 |
+
});
|
534 |
+
|
535 |
+
// 添加到队列
|
536 |
+
const dataStr = `data: ${JSON.stringify(chunk)}\n\n`;
|
537 |
+
if (!safeWrite(dataStr)) {
|
538 |
+
// 如果写入失败,结束处理
|
539 |
+
try {
|
540 |
+
reader.destroy();
|
541 |
+
} catch (error) {
|
542 |
+
logger.error(`写入失败后销毁reader时出错: ${error.message}`);
|
543 |
+
}
|
544 |
+
return;
|
545 |
+
}
|
546 |
+
} else if (jsonData?.recordMap) {
|
547 |
+
// 忽略recordMap响应
|
548 |
+
} else {
|
549 |
+
// 忽略其他类型响应
|
550 |
+
}
|
551 |
+
} catch (jsonError) {
|
552 |
+
logger.error(`解析JSON出错: ${jsonError}`);
|
553 |
+
}
|
554 |
+
}
|
555 |
+
} catch (error) {
|
556 |
+
logger.error(`处理数据块出错: ${error}`);
|
557 |
+
}
|
558 |
+
});
|
559 |
+
|
560 |
+
// 处理流结束
|
561 |
+
reader.on('end', () => {
|
562 |
+
try {
|
563 |
+
logger.info(`响应完成`);
|
564 |
+
if (cookieManager.getValidCount() > 1){
|
565 |
+
// 尝试切换到下一个cookie
|
566 |
+
currentCookieData = cookieManager.getNext();
|
567 |
+
logger.info(`切换到下一个cookie: ${currentCookieData.userId}`);
|
568 |
+
}
|
569 |
+
|
570 |
+
// 如果没有收到任何响应,发送一个提示消息
|
571 |
+
if (!responseReceived) {
|
572 |
+
if (!ENABLE_PROXY_SERVER){
|
573 |
+
logger.warning(`未从Notion收到内容响应,请尝试启用tls代理服务`)
|
574 |
+
}else if (USE_NATIVE_PROXY_POOL){
|
575 |
+
logger.warning(`未从Notion收到内容响应,请重roll,或者切换cookie`)
|
576 |
+
}else{
|
577 |
+
logger.warning(`未从Notion收到内容响应,请更换ip重试`);
|
578 |
+
}
|
579 |
+
if (USE_NATIVE_PROXY_POOL) {
|
580 |
+
proxyPool.removeProxy(proxy.ip, proxy.port);
|
581 |
+
}
|
582 |
+
|
583 |
+
const noContentChunk = new ChatCompletionChunk({
|
584 |
+
choices: [
|
585 |
+
new Choice({
|
586 |
+
delta: new ChoiceDelta({ content: "未从Notion收到内容响应,请更换ip重试。" }),
|
587 |
+
finish_reason: "no_content"
|
588 |
+
})
|
589 |
+
]
|
590 |
+
});
|
591 |
+
safeWrite(`data: ${JSON.stringify(noContentChunk)}\n\n`);
|
592 |
+
}
|
593 |
+
|
594 |
+
// 创建结束块
|
595 |
+
const endChunk = new ChatCompletionChunk({
|
596 |
+
choices: [
|
597 |
+
new Choice({
|
598 |
+
delta: new ChoiceDelta({ content: null }),
|
599 |
+
finish_reason: "stop"
|
600 |
+
})
|
601 |
+
]
|
602 |
+
});
|
603 |
+
|
604 |
+
// 添加到队列
|
605 |
+
safeWrite(`data: ${JSON.stringify(endChunk)}\n\n`);
|
606 |
+
safeWrite('data: [DONE]\n\n');
|
607 |
+
|
608 |
+
// 清除超时计时器(如果尚未清除)
|
609 |
+
if (timeoutId) clearTimeout(timeoutId);
|
610 |
+
|
611 |
+
// 清理全局对象
|
612 |
+
try {
|
613 |
+
if (global.window) delete global.window;
|
614 |
+
if (global.document) delete global.document;
|
615 |
+
|
616 |
+
// 安全地删除navigator
|
617 |
+
if (global.navigator) {
|
618 |
+
try {
|
619 |
+
delete global.navigator;
|
620 |
+
} catch (navError) {
|
621 |
+
// 如果无法删除,尝试将其设置为undefined
|
622 |
+
try {
|
623 |
+
Object.defineProperty(global, 'navigator', {
|
624 |
+
value: undefined,
|
625 |
+
writable: true,
|
626 |
+
configurable: true
|
627 |
+
});
|
628 |
+
} catch (defineError) {
|
629 |
+
logger.warning(`无法清理navigator: ${defineError.message}`);
|
630 |
+
}
|
631 |
+
}
|
632 |
+
}
|
633 |
+
} catch (cleanupError) {
|
634 |
+
logger.warning(`清理全局对象���出错: ${cleanupError.message}`);
|
635 |
+
}
|
636 |
+
|
637 |
+
// 结束流
|
638 |
+
if (!isStreamClosed()) {
|
639 |
+
chunkQueue.end();
|
640 |
+
}
|
641 |
+
} catch (error) {
|
642 |
+
logger.error(`Error in stream end handler: ${error}`);
|
643 |
+
if (timeoutId) clearTimeout(timeoutId);
|
644 |
+
|
645 |
+
// 清理全局对象
|
646 |
+
try {
|
647 |
+
if (global.window) delete global.window;
|
648 |
+
if (global.document) delete global.document;
|
649 |
+
|
650 |
+
// 安全地删除navigator
|
651 |
+
if (global.navigator) {
|
652 |
+
try {
|
653 |
+
delete global.navigator;
|
654 |
+
} catch (navError) {
|
655 |
+
// 如果无法删除,尝试将其设置为undefined
|
656 |
+
try {
|
657 |
+
Object.defineProperty(global, 'navigator', {
|
658 |
+
value: undefined,
|
659 |
+
writable: true,
|
660 |
+
configurable: true
|
661 |
+
});
|
662 |
+
} catch (defineError) {
|
663 |
+
logger.warning(`无法清理navigator: ${defineError.message}`);
|
664 |
+
}
|
665 |
+
}
|
666 |
+
}
|
667 |
+
} catch (cleanupError) {
|
668 |
+
logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
|
669 |
+
}
|
670 |
+
|
671 |
+
if (!isStreamClosed()) {
|
672 |
+
chunkQueue.end();
|
673 |
+
}
|
674 |
+
}
|
675 |
+
});
|
676 |
+
|
677 |
+
// 处理错误
|
678 |
+
reader.on('error', (error) => {
|
679 |
+
logger.error(`Stream error: ${error}`);
|
680 |
+
if (timeoutId) clearTimeout(timeoutId);
|
681 |
+
|
682 |
+
// 清理全局对象
|
683 |
+
try {
|
684 |
+
if (global.window) delete global.window;
|
685 |
+
if (global.document) delete global.document;
|
686 |
+
|
687 |
+
// 安全地删除navigator
|
688 |
+
if (global.navigator) {
|
689 |
+
try {
|
690 |
+
delete global.navigator;
|
691 |
+
} catch (navError) {
|
692 |
+
// 如果无法删除,尝试将其设置为undefined
|
693 |
+
try {
|
694 |
+
Object.defineProperty(global, 'navigator', {
|
695 |
+
value: undefined,
|
696 |
+
writable: true,
|
697 |
+
configurable: true
|
698 |
+
});
|
699 |
+
} catch (defineError) {
|
700 |
+
logger.warning(`无法清理navigator: ${defineError.message}`);
|
701 |
+
}
|
702 |
+
}
|
703 |
+
}
|
704 |
+
} catch (cleanupError) {
|
705 |
+
logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
|
706 |
+
}
|
707 |
+
|
708 |
+
try {
|
709 |
+
const errorChunk = new ChatCompletionChunk({
|
710 |
+
choices: [
|
711 |
+
new Choice({
|
712 |
+
delta: new ChoiceDelta({ content: `流读取错误: ${error.message}` }),
|
713 |
+
finish_reason: "error"
|
714 |
+
})
|
715 |
+
]
|
716 |
+
});
|
717 |
+
safeWrite(`data: ${JSON.stringify(errorChunk)}\n\n`);
|
718 |
+
safeWrite('data: [DONE]\n\n');
|
719 |
+
} catch (e) {
|
720 |
+
logger.error(`Error sending error message: ${e}`);
|
721 |
+
} finally {
|
722 |
+
if (!isStreamClosed()) {
|
723 |
+
chunkQueue.end();
|
724 |
+
}
|
725 |
+
}
|
726 |
+
});
|
727 |
+
} catch (error) {
|
728 |
+
logger.error(`Notion API请求失败: ${error}`);
|
729 |
+
// 清理全局对象
|
730 |
+
try {
|
731 |
+
if (global.window) delete global.window;
|
732 |
+
if (global.document) delete global.document;
|
733 |
+
|
734 |
+
// 安全地删除navigator
|
735 |
+
if (global.navigator) {
|
736 |
+
try {
|
737 |
+
delete global.navigator;
|
738 |
+
} catch (navError) {
|
739 |
+
// 如果无法删除,尝试将其设置为undefined
|
740 |
+
try {
|
741 |
+
Object.defineProperty(global, 'navigator', {
|
742 |
+
value: undefined,
|
743 |
+
writable: true,
|
744 |
+
configurable: true
|
745 |
+
});
|
746 |
+
} catch (defineError) {
|
747 |
+
logger.warning(`无法清理navigator: ${defineError.message}`);
|
748 |
+
}
|
749 |
+
}
|
750 |
+
}
|
751 |
+
} catch (cleanupError) {
|
752 |
+
logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
|
753 |
+
}
|
754 |
+
|
755 |
+
if (timeoutId) clearTimeout(timeoutId);
|
756 |
+
|
757 |
+
// 确保在错误情况下也触发流结束
|
758 |
+
try {
|
759 |
+
if (!responseReceived && !isStreamClosed()) {
|
760 |
+
const errorChunk = new ChatCompletionChunk({
|
761 |
+
choices: [
|
762 |
+
new Choice({
|
763 |
+
delta: new ChoiceDelta({ content: `Notion API请求失败: ${error.message}` }),
|
764 |
+
finish_reason: "error"
|
765 |
+
})
|
766 |
+
]
|
767 |
+
});
|
768 |
+
safeWrite(`data: ${JSON.stringify(errorChunk)}\n\n`);
|
769 |
+
safeWrite('data: [DONE]\n\n');
|
770 |
+
}
|
771 |
+
} catch (e) {
|
772 |
+
logger.error(`发送错误消息时出错: ${e}`);
|
773 |
+
}
|
774 |
+
|
775 |
+
if (!isStreamClosed()) {
|
776 |
+
chunkQueue.end();
|
777 |
+
}
|
778 |
+
|
779 |
+
throw error; // 重新抛出错误以便上层捕获
|
780 |
+
}
|
781 |
+
}
|
782 |
+
|
783 |
+
// 应用初始化
|
784 |
+
async function initialize() {
|
785 |
+
logger.info(`初始化Notion配置...`);
|
786 |
+
|
787 |
+
// 启动代理服务器
|
788 |
+
try {
|
789 |
+
await proxyServer.start();
|
790 |
+
} catch (error) {
|
791 |
+
logger.error(`启动代理服务器失败: ${error.message}`);
|
792 |
+
}
|
793 |
+
|
794 |
+
// 初始化cookie管理器
|
795 |
+
let initResult = false;
|
796 |
+
|
797 |
+
// 检查是否配置了cookie文件
|
798 |
+
const cookieFilePath = process.env.COOKIE_FILE;
|
799 |
+
if (cookieFilePath) {
|
800 |
+
logger.info(`检测到COOKIE_FILE配置: ${cookieFilePath}`);
|
801 |
+
initResult = await cookieManager.loadFromFile(cookieFilePath);
|
802 |
+
|
803 |
+
if (!initResult) {
|
804 |
+
logger.error(`从文件加载cookie失败,尝试使用环境变量中的NOTION_COOKIE`);
|
805 |
+
}
|
806 |
+
}
|
807 |
+
|
808 |
+
// 如果文件加载失败或未配置文件,尝试从环境变量加载
|
809 |
+
if (!initResult) {
|
810 |
+
const cookiesString = process.env.NOTION_COOKIE;
|
811 |
+
if (!cookiesString) {
|
812 |
+
logger.error(`错误: 未设置NOTION_COOKIE环境变量或COOKIE_FILE路径,应用无法正常工作`);
|
813 |
+
logger.error(`请在.env文件中设置有效的NOTION_COOKIE值或COOKIE_FILE路径`);
|
814 |
+
INITIALIZED_SUCCESSFULLY = false;
|
815 |
+
return;
|
816 |
+
}
|
817 |
+
|
818 |
+
logger.info(`正在从环境变量初始化cookie管理器...`);
|
819 |
+
initResult = await cookieManager.initialize(cookiesString);
|
820 |
+
|
821 |
+
if (!initResult) {
|
822 |
+
logger.error(`初始化cookie管理器失败,应用无法正常工作`);
|
823 |
+
INITIALIZED_SUCCESSFULLY = false;
|
824 |
+
return;
|
825 |
+
}
|
826 |
+
}
|
827 |
+
|
828 |
+
// 获取第一个可用的cookie数据
|
829 |
+
currentCookieData = cookieManager.getNext();
|
830 |
+
if (!currentCookieData) {
|
831 |
+
logger.error(`没有可用的cookie,应用无法正常工作`);
|
832 |
+
INITIALIZED_SUCCESSFULLY = false;
|
833 |
+
return;
|
834 |
+
}
|
835 |
+
|
836 |
+
logger.success(`成功初始化cookie管理器,共有 ${cookieManager.getValidCount()} 个有效cookie`);
|
837 |
+
logger.info(`当前使用的cookie对应的用户ID: ${currentCookieData.userId}`);
|
838 |
+
logger.info(`当前使用的cookie对应的空间ID: ${currentCookieData.spaceId}`);
|
839 |
+
|
840 |
+
if (process.env.USE_NATIVE_PROXY_POOL === 'true') {
|
841 |
+
logger.info(`正在初始化本地代理池...`);
|
842 |
+
// 设置代理池的日志级别为warn,减少详细日志输出
|
843 |
+
proxyPool.logLevel = 'warn';
|
844 |
+
await proxyPool.initialize();
|
845 |
+
}
|
846 |
+
|
847 |
+
INITIALIZED_SUCCESSFULLY = true;
|
848 |
+
}
|
849 |
+
|
850 |
+
// 导出函数
|
851 |
+
export {
|
852 |
+
initialize,
|
853 |
+
streamNotionResponse,
|
854 |
+
buildNotionRequest,
|
855 |
+
INITIALIZED_SUCCESSFULLY
|
856 |
+
};
|
src/models.js
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { randomUUID } from 'crypto';
|
2 |
+
|
3 |
+
// 输入模型 (OpenAI-like)
|
4 |
+
export class ChatMessage {
|
5 |
+
constructor({
|
6 |
+
id = generateCustomId(),
|
7 |
+
role,
|
8 |
+
content,
|
9 |
+
userId = null,
|
10 |
+
createdAt = null,
|
11 |
+
traceId = null
|
12 |
+
}) {
|
13 |
+
this.id = id;
|
14 |
+
this.role = role; // "system", "user", "assistant"
|
15 |
+
this.content = content;
|
16 |
+
this.userId = userId;
|
17 |
+
this.createdAt = createdAt;
|
18 |
+
this.traceId = traceId;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
export class ChatCompletionRequest {
|
23 |
+
constructor({
|
24 |
+
messages,
|
25 |
+
model = "notion-proxy",
|
26 |
+
stream = false,
|
27 |
+
notion_model = "anthropic-opus-4"
|
28 |
+
}) {
|
29 |
+
this.messages = messages;
|
30 |
+
this.model = model;
|
31 |
+
this.stream = stream;
|
32 |
+
this.notion_model = notion_model;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
// Notion 模型
|
37 |
+
export class NotionTranscriptConfigValue {
|
38 |
+
constructor({
|
39 |
+
type = "markdown-chat",
|
40 |
+
model
|
41 |
+
}) {
|
42 |
+
this.type = type;
|
43 |
+
this.model = model;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
export class NotionTranscriptContextValue {
|
49 |
+
constructor({
|
50 |
+
userId,
|
51 |
+
spaceId,
|
52 |
+
surface = "home_module",
|
53 |
+
timezone = "America/Los_Angeles",
|
54 |
+
userName,
|
55 |
+
spaceName,
|
56 |
+
spaceViewId,
|
57 |
+
currentDatetime
|
58 |
+
}) {
|
59 |
+
this.userId = userId;
|
60 |
+
this.spaceId = spaceId;
|
61 |
+
this.surface = surface;
|
62 |
+
this.timezone = timezone;
|
63 |
+
this.userName = userName;
|
64 |
+
this.spaceName = spaceName;
|
65 |
+
this.spaceViewId = spaceViewId;
|
66 |
+
this.currentDatetime = currentDatetime;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
export class NotionTranscriptItem {
|
71 |
+
constructor({
|
72 |
+
id = generateCustomId(),
|
73 |
+
type,
|
74 |
+
value = null,
|
75 |
+
|
76 |
+
}) {
|
77 |
+
this.id = id;
|
78 |
+
this.type = type; // "markdown-chat", "agent-integration", "context"
|
79 |
+
this.value = value;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
export class NotionTranscriptItemByuser {
|
84 |
+
constructor({
|
85 |
+
id = generateCustomId(),
|
86 |
+
type,
|
87 |
+
value = null,
|
88 |
+
userId,
|
89 |
+
createdAt
|
90 |
+
|
91 |
+
}) {
|
92 |
+
this.id = id;
|
93 |
+
this.type = type; // "config", "user"
|
94 |
+
this.value = value;
|
95 |
+
this.userId = userId;
|
96 |
+
this.createdAt = createdAt;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
export class NotionDebugOverrides {
|
101 |
+
constructor({
|
102 |
+
cachedInferences = {},
|
103 |
+
annotationInferences = {},
|
104 |
+
emitInferences = false
|
105 |
+
}) {
|
106 |
+
this.cachedInferences = cachedInferences;
|
107 |
+
this.annotationInferences = annotationInferences;
|
108 |
+
this.emitInferences = emitInferences;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
export function generateCustomId() {
|
113 |
+
// 创建固定部分
|
114 |
+
const prefix1 = '2036702a';
|
115 |
+
const prefix2 = '4d19';
|
116 |
+
const prefix5 = '00aa';
|
117 |
+
|
118 |
+
// 生成随机十六进制字符
|
119 |
+
function randomHex(length) {
|
120 |
+
return Array(length).fill(0).map(() =>
|
121 |
+
Math.floor(Math.random() * 16).toString(16)
|
122 |
+
).join('');
|
123 |
+
}
|
124 |
+
|
125 |
+
// 组合所有部分
|
126 |
+
const part3 = '80' + randomHex(2); // 8xxx
|
127 |
+
const part4 = randomHex(4); // xxxx
|
128 |
+
const part5 = prefix5 + randomHex(8); // 00aaxxxxxxxx
|
129 |
+
|
130 |
+
return `${prefix1}-${prefix2}-${part3}-${part4}-${part5}`;
|
131 |
+
}
|
132 |
+
|
133 |
+
export class NotionRequestBody {
|
134 |
+
constructor({
|
135 |
+
traceId = randomUUID(),
|
136 |
+
spaceId,
|
137 |
+
transcript,
|
138 |
+
createThread = false,
|
139 |
+
debugOverrides = new NotionDebugOverrides({}),
|
140 |
+
generateTitle = true,
|
141 |
+
saveAllThreadOperations = true,
|
142 |
+
}) {
|
143 |
+
this.traceId = traceId;
|
144 |
+
this.spaceId = spaceId;
|
145 |
+
this.transcript = transcript;
|
146 |
+
this.createThread = createThread;
|
147 |
+
this.debugOverrides = debugOverrides;
|
148 |
+
this.generateTitle = generateTitle;
|
149 |
+
this.saveAllThreadOperations = saveAllThreadOperations;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
// 输出模型 (OpenAI SSE)
|
154 |
+
export class ChoiceDelta {
|
155 |
+
constructor({
|
156 |
+
content = null
|
157 |
+
}) {
|
158 |
+
this.content = content;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
export class Choice {
|
163 |
+
constructor({
|
164 |
+
index = 0,
|
165 |
+
delta,
|
166 |
+
finish_reason = null
|
167 |
+
}) {
|
168 |
+
this.index = index;
|
169 |
+
this.delta = delta;
|
170 |
+
this.finish_reason = finish_reason;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
export class ChatCompletionChunk {
|
175 |
+
constructor({
|
176 |
+
id = `chatcmpl-${randomUUID()}`,
|
177 |
+
object = "chat.completion.chunk",
|
178 |
+
created = Math.floor(Date.now() / 1000),
|
179 |
+
model = "notion-proxy",
|
180 |
+
choices
|
181 |
+
}) {
|
182 |
+
this.id = id;
|
183 |
+
this.object = object;
|
184 |
+
this.created = created;
|
185 |
+
this.model = model;
|
186 |
+
this.choices = choices;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
// 模型列表端点 /v1/models
|
191 |
+
export class Model {
|
192 |
+
constructor({
|
193 |
+
id,
|
194 |
+
object = "model",
|
195 |
+
created = Math.floor(Date.now() / 1000),
|
196 |
+
owned_by = "notion"
|
197 |
+
}) {
|
198 |
+
this.id = id;
|
199 |
+
this.object = object;
|
200 |
+
this.created = created;
|
201 |
+
this.owned_by = owned_by;
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
export class ModelList {
|
206 |
+
constructor({
|
207 |
+
object = "list",
|
208 |
+
data
|
209 |
+
}) {
|
210 |
+
this.object = object;
|
211 |
+
this.data = data;
|
212 |
+
}
|
213 |
+
}
|
src/proxy/chrome_proxy_server_linux_amd64
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2e33e31ff51fb711daff95ca41f84e5f56dbfc9c57b90df3761bc1d69e57bfa9
|
3 |
+
size 12845606
|