Initial commit: OpenAI Codex reverse proxy with Node.js + Express

This commit is contained in:
lulistart
2026-02-17 08:50:58 +08:00
commit 5e3cbb0eca
10 changed files with 1993 additions and 0 deletions

8
.env.exa Normal file
View File

@@ -0,0 +1,8 @@
# 服务器端口
PORT=3000
# Token 文件路径
TOKEN_FILE=./token.json
# 模型列表文件路径
MODELS_FILE=./models.json

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
node_modules/
.env
token.json
*.log
.DS_Store

284
README.md Normal file
View File

@@ -0,0 +1,284 @@
# GPT2API Node
基于 Node.js + Express 的 OpenAI Codex 反向代理服务,支持 JSON 文件导入 token自动刷新 token提供 OpenAI 兼容的 API 接口。
## 功能特性
- ✅ OpenAI Codex 反向代理
- ✅ 自动 Token 刷新机制
- ✅ 支持流式和非流式响应
- ✅ OpenAI API 兼容接口
- ✅ JSON 文件导入 Token
- ✅ 简单易用的配置
## 快速开始
### 1. 安装依赖
```bash
cd gpt2api-node
npm install
```
### 2. 配置 Token
从 CLIProxyAPI 或其他来源获取 token 文件,复制到项目根目录并命名为 `token.json`
```json
{
"id_token": "your_id_token_here",
"access_token": "your_access_token_here",
"refresh_token": "your_refresh_token_here",
"account_id": "your_account_id",
"email": "your_email@example.com",
"type": "codex",
"expired": "2026-12-31T23:59:59.000Z",
"last_refresh": "2026-01-01T00:00:00.000Z"
}
```
### 3. 配置环境变量(可选)
复制 `.env.example``.env` 并修改配置:
```bash
cp .env.example .env
```
```env
PORT=3000
TOKEN_FILE=./token.json
```
### 4. 启动服务
```bash
npm start
```
开发模式(自动重启):
```bash
npm run dev
```
## API 接口
### 聊天完成接口
**端点**: `POST /v1/chat/completions`
**请求示例**:
```bash
curl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"messages": [
{"role": "user", "content": "Hello!"}
],
"stream": false
}'
```
**流式请求**:
```bash
curl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"messages": [
{"role": "user", "content": "Hello!"}
],
"stream": true
}'
```
### 模型列表
**端点**: `GET /v1/models`
```bash
curl http://localhost:3000/v1/models
```
### 健康检查
**端点**: `GET /health`
```bash
curl http://localhost:3000/health
```
## 支持的模型
- `gpt-5.3-codex` - GPT 5.3 Codex最新
- `gpt-5.3-codex-spark` - GPT 5.3 Codex Spark超快速编码模型
- `gpt-5.2` - GPT 5.2
- `gpt-5.2-codex` - GPT 5.2 Codex
- `gpt-5.1` - GPT 5.1
- `gpt-5.1-codex` - GPT 5.1 Codex
- `gpt-5.1-codex-mini` - GPT 5.1 Codex Mini更快更便宜
- `gpt-5.1-codex-max` - GPT 5.1 Codex Max
- `gpt-5` - GPT 5
- `gpt-5-codex` - GPT 5 Codex
- `gpt-5-codex-mini` - GPT 5 Codex Mini
## 在 Cherry Studio 中使用
Cherry Studio 是一个支持多种 AI 服务的桌面客户端。配置步骤:
### 1. 启动代理服务
```bash
cd gpt2api-node
npm start
```
### 2. 在 Cherry Studio 中配置
1. 打开 Cherry Studio
2. 进入 **设置****模型提供商**
3. 添加新的 **OpenAI 兼容** 提供商
4. 填写配置:
- **名称**: GPT2API Node或自定义名称
- **API 地址**: `http://localhost:3000/v1`
- **API Key**: 随意填写(如 `dummy`),不会被验证
- **模型**: 选择或手动输入模型名称(如 `gpt-5.3-codex`
### 3. 开始使用
配置完成后,在 Cherry Studio 中选择刚才添加的提供商和模型,即可开始对话。
### 可用模型列表
在 Cherry Studio 中可以使用以下任意模型:
- `gpt-5.3-codex` - 推荐,最新版本
- `gpt-5.3-codex-spark` - 超快速编码
- `gpt-5.2-codex` - 稳定版本
- `gpt-5.1-codex` - 较旧版本
- 其他 GPT-5 系列模型
## 使用示例
### Python
```python
import openai
client = openai.OpenAI(
base_url="http://localhost:3000/v1",
api_key="dummy" # 不需要真实的 API key
)
response = client.chat.completions.create(
model="gpt-5.3-codex",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
```
### JavaScript/Node.js
```javascript
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'http://localhost:3000/v1',
apiKey: 'dummy'
});
const response = await client.chat.completions.create({
model: 'gpt-5.3-codex',
messages: [
{ role: 'user', content: 'Hello!' }
]
});
console.log(response.choices[0].message.content);
```
### cURL
```bash
curl http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}'
```
## Token 管理
### 自动刷新
服务会自动检测 token 是否过期(提前 5 分钟),并在需要时自动刷新。刷新后的 token 会自动保存到文件中。
### 手动导入
如果你有从 CLIProxyAPI 导出的 token 文件,直接复制为 `token.json` 即可使用。
### Token 文件格式
Token 文件必须包含以下字段:
- `access_token`: 访问令牌
- `refresh_token`: 刷新令牌
- `id_token`: ID 令牌(可选)
- `account_id`: 账户 ID可选
- `email`: 邮箱(可选)
- `expired`: 过期时间ISO 8601 格式)
- `type`: 类型(固定为 "codex"
## 项目结构
```
gpt2api-node/
├── src/
│ ├── index.js # 主服务器文件
│ ├── tokenManager.js # Token 管理模块
│ └── proxyHandler.js # 代理处理模块
├── package.json
├── .env.example
├── token.example.json
├── .gitignore
└── README.md
```
## 注意事项
1. **Token 安全**: 请妥善保管 `token.json` 文件,不要提交到版本控制系统
2. **网络要求**: 需要能够访问 `chatgpt.com``auth.openai.com`
3. **Token 有效期**: Token 会自动刷新,但如果 refresh_token 失效,需要重新获取
4. **并发限制**: 根据 OpenAI 账户限制,注意控制并发请求数量
## 故障排除
### Token 加载失败
确保 `token.json` 文件存在且格式正确,参考 `token.example.json`
### Token 刷新失败
可能是 refresh_token 已过期,需要重新从 CLIProxyAPI 获取新的 token。
### 代理请求失败
检查网络连接,确保能够访问 OpenAI 服务。
## 许可证
MIT License
## 相关项目
- [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) - 原始 Go 语言实现

68
models.json Normal file
View File

@@ -0,0 +1,68 @@
[
{
"id": "gpt-5.3-codex",
"object": "model",
"created": 1770307200,
"owned_by": "openai"
},
{
"id": "gpt-5.3-codex-spark",
"object": "model",
"created": 1770912000,
"owned_by": "openai"
},
{
"id": "gpt-5.2",
"object": "model",
"created": 1765440000,
"owned_by": "openai"
},
{
"id": "gpt-5.2-codex",
"object": "model",
"created": 1765440000,
"owned_by": "openai"
},
{
"id": "gpt-5.1",
"object": "model",
"created": 1762905600,
"owned_by": "openai"
},
{
"id": "gpt-5.1-codex",
"object": "model",
"created": 1762905600,
"owned_by": "openai"
},
{
"id": "gpt-5.1-codex-mini",
"object": "model",
"created": 1762905600,
"owned_by": "openai"
},
{
"id": "gpt-5.1-codex-max",
"object": "model",
"created": 1763424000,
"owned_by": "openai"
},
{
"id": "gpt-5",
"object": "model",
"created": 1754524800,
"owned_by": "openai"
},
{
"id": "gpt-5-codex",
"object": "model",
"created": 1757894400,
"owned_by": "openai"
},
{
"id": "gpt-5-codex-mini",
"object": "model",
"created": 1762473600,
"owned_by": "openai"
}
]

952
package-lock.json generated Normal file
View File

@@ -0,0 +1,952 @@
{
"name": "gpt2api-node",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gpt2api-node",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"axios": "^1.6.0",
"dotenv": "^16.3.1",
"express": "^4.18.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmmirror.com/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.13.5",
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.13.5.tgz",
"integrity": "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.11",
"form-data": "^4.0.5",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/body-parser": {
"version": "1.20.4",
"resolved": "https://registry.npmmirror.com/body-parser/-/body-parser-1.20.4.tgz",
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.14.0",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmmirror.com/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmmirror.com/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmmirror.com/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmmirror.com/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmmirror.com/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmmirror.com/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dotenv": {
"version": "16.6.1",
"resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-16.6.1.tgz",
"integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmmirror.com/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-set-tostringtag": {
"version": "2.1.0",
"resolved": "https://registry.npmmirror.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.6",
"has-tostringtag": "^1.0.2",
"hasown": "^2.0.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmmirror.com/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.1",
"resolved": "https://registry.npmmirror.com/express/-/express-4.22.1.tgz",
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.3",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.12",
"proxy-addr": "~2.0.7",
"qs": "~6.14.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmmirror.com/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/follow-redirects": {
"version": "1.15.11",
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.11.tgz",
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.5",
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.5.tgz",
"integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"es-set-tostringtag": "^2.1.0",
"hasown": "^2.0.2",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmmirror.com/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmmirror.com/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-tostringtag": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
"license": "MIT",
"dependencies": {
"has-symbols": "^1.0.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmmirror.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmmirror.com/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmmirror.com/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmmirror.com/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmmirror.com/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.12",
"resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmmirror.com/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"license": "MIT"
},
"node_modules/qs": {
"version": "6.14.2",
"resolved": "https://registry.npmmirror.com/qs/-/qs-6.14.2.tgz",
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmmirror.com/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmmirror.com/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmmirror.com/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmmirror.com/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmmirror.com/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/side-channel-list/-/side-channel-list-1.0.0.tgz",
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmmirror.com/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmmirror.com/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}

19
package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "gpt2api-node",
"version": "1.0.0",
"description": "OpenAI Codex reverse proxy with token management",
"main": "src/index.js",
"type": "module",
"scripts": {
"start": "node src/index.js",
"dev": "node --watch src/index.js"
},
"keywords": ["openai", "codex", "proxy", "api"],
"author": "",
"license": "MIT",
"dependencies": {
"express": "^4.18.2",
"axios": "^1.6.0",
"dotenv": "^16.3.1"
}
}

92
src/index.js Normal file
View File

@@ -0,0 +1,92 @@
import express from 'express';
import dotenv from 'dotenv';
import fs from 'fs/promises';
import TokenManager from './tokenManager.js';
import ProxyHandler from './proxyHandler.js';
dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
const TOKEN_FILE = process.env.TOKEN_FILE || './token.json';
const MODELS_FILE = process.env.MODELS_FILE || './models.json';
// 中间件
app.use(express.json());
// 初始化 Token 管理器和代理处理器
const tokenManager = new TokenManager(TOKEN_FILE);
const proxyHandler = new ProxyHandler(tokenManager);
// 加载模型列表
let modelsList = [];
try {
const modelsData = await fs.readFile(MODELS_FILE, 'utf-8');
modelsList = JSON.parse(modelsData);
console.log(`✓ 加载了 ${modelsList.length} 个模型`);
} catch (err) {
console.warn('⚠ 无法加载模型列表,使用默认列表');
modelsList = [
{ id: 'gpt-5.3-codex', object: 'model', created: 1770307200, owned_by: 'openai' },
{ id: 'gpt-5.2-codex', object: 'model', created: 1765440000, owned_by: 'openai' }
];
}
// 启动时加载 token
await tokenManager.loadToken().catch(err => {
console.error('❌ 启动失败:', err.message);
console.error('请确保 token.json 文件存在且格式正确');
process.exit(1);
});
// 健康检查
app.get('/health', (req, res) => {
res.json({
status: 'ok',
token: tokenManager.getTokenInfo()
});
});
// OpenAI 兼容的聊天完成接口
app.post('/v1/chat/completions', async (req, res) => {
const isStream = req.body.stream === true;
if (isStream) {
await proxyHandler.handleStreamRequest(req, res);
} else {
await proxyHandler.handleNonStreamRequest(req, res);
}
});
// 模型列表接口
app.get('/v1/models', (req, res) => {
res.json({
object: 'list',
data: modelsList
});
});
// 错误处理
app.use((err, req, res, next) => {
console.error('服务器错误:', err);
res.status(500).json({
error: {
message: err.message || '内部服务器错误',
type: 'server_error'
}
});
});
// 启动服务器
app.listen(PORT, () => {
console.log('=================================');
console.log('🚀 GPT2API Node 服务已启动');
console.log(`📡 监听端口: ${PORT}`);
console.log(`👤 账户: ${tokenManager.getTokenInfo().email || tokenManager.getTokenInfo().account_id}`);
console.log(`⏰ Token 过期时间: ${tokenManager.getTokenInfo().expired}`);
console.log('=================================');
console.log(`\n接口地址:`);
console.log(` - 聊天: POST http://localhost:${PORT}/v1/chat/completions`);
console.log(` - 模型: GET http://localhost:${PORT}/v1/models`);
console.log(` - 健康: GET http://localhost:${PORT}/health\n`);
});

423
src/proxyHandler.js Normal file
View File

@@ -0,0 +1,423 @@
import axios from 'axios';
const CODEX_BASE_URL = 'https://chatgpt.com/backend-api/codex';
const CODEX_CLIENT_VERSION = '0.101.0';
const CODEX_USER_AGENT = 'codex_cli_rs/0.101.0 (Mac OS 26.0.1; arm64) Apple_Terminal/464';
/**
* 代理处理器
*/
class ProxyHandler {
constructor(tokenManager) {
this.tokenManager = tokenManager;
}
/**
* 生成会话 ID
*/
generateSessionId() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
/**
* 转换 OpenAI 格式请求到 Codex 格式
*/
transformRequest(openaiRequest) {
const { model, messages, stream = true, stream_options, ...rest } = openaiRequest;
// 提取 system 消息作为 instructions
let instructions = '';
const userMessages = [];
for (const msg of messages) {
if (msg.role === 'system') {
// system 消息转为 instructions
const content = Array.isArray(msg.content)
? msg.content.map(c => c.text || c).join('\n')
: msg.content;
instructions += (instructions ? '\n' : '') + content;
} else {
// 其他消息保留
userMessages.push(msg);
}
}
// 转换消息格式
const input = userMessages.map(msg => {
const contentType = msg.role === 'assistant' ? 'output_text' : 'input_text';
return {
type: 'message',
role: msg.role,
content: Array.isArray(msg.content)
? msg.content.map(c => {
// 处理不同类型的内容
if (c.type === 'text') {
return { type: contentType, text: c.text || c };
} else if (c.type === 'image_url') {
// OpenAI 的 image_url 转换为 Codex 的 input_image
return {
type: 'input_image',
image_url: c.image_url?.url || c.image_url
};
} else {
return c;
}
})
: [{ type: contentType, text: msg.content }]
};
});
// 移除 Codex 不支持的参数
const codexRequest = {
model: model || 'gpt-5.3-codex',
input,
instructions: instructions || '',
stream,
store: false // 必须设置为 false
};
// 只保留 Codex 支持的参数
if (rest.temperature !== undefined) codexRequest.temperature = rest.temperature;
if (rest.max_tokens !== undefined) codexRequest.max_tokens = rest.max_tokens;
if (rest.top_p !== undefined) codexRequest.top_p = rest.top_p;
return codexRequest;
}
/**
* 转换 Codex 响应到 OpenAI 格式
*/
transformResponse(codexResponse, model, isStream = false, state = {}) {
if (isStream) {
// 流式响应处理
const line = codexResponse.toString().trim();
if (!line.startsWith('data:')) {
return null;
}
const data = line.slice(5).trim();
if (data === '[DONE]') {
return 'data: [DONE]\n\n';
}
try {
const parsed = JSON.parse(data);
// 保存响应 ID 和创建时间
if (parsed.type === 'response.created') {
state.responseId = parsed.response?.id;
state.createdAt = parsed.response?.created_at || Math.floor(Date.now() / 1000);
state.model = parsed.response?.model || model;
return null;
}
const responseId = state.responseId || 'chatcmpl-' + Date.now();
const createdAt = state.createdAt || Math.floor(Date.now() / 1000);
const modelName = state.model || model;
// 处理不同类型的事件 - 根据原项目的实现
if (parsed.type === 'response.output_text.delta') {
// 文本增量更新
return `data: ${JSON.stringify({
id: responseId,
object: 'chat.completion.chunk',
created: createdAt,
model: modelName,
choices: [{
index: 0,
delta: { role: 'assistant', content: parsed.delta || '' },
finish_reason: null
}]
})}\n\n`;
} else if (parsed.type === 'response.reasoning_summary_text.delta') {
// 推理内容增量
return `data: ${JSON.stringify({
id: responseId,
object: 'chat.completion.chunk',
created: createdAt,
model: modelName,
choices: [{
index: 0,
delta: { role: 'assistant', reasoning_content: parsed.delta || '' },
finish_reason: null
}]
})}\n\n`;
} else if (parsed.type === 'response.completed') {
// 提取使用信息
const usage = parsed.response?.usage || {};
return `data: ${JSON.stringify({
id: parsed.response_id || 'chatcmpl-' + Date.now(),
object: 'chat.completion.chunk',
created: Math.floor(Date.now() / 1000),
model: model,
choices: [{
index: 0,
delta: {},
finish_reason: 'stop'
}],
usage: {
prompt_tokens: usage.input_tokens || 0,
completion_tokens: usage.output_tokens || 0,
total_tokens: usage.total_tokens || 0
}
})}\n\n`;
}
} catch (e) {
// 忽略 JSON 解析错误,可能是不完整的数据
return null;
}
return null;
} else {
// 非流式响应处理
try {
const parsed = typeof codexResponse === 'string'
? JSON.parse(codexResponse)
: codexResponse;
const response = parsed.response || {};
const output = response.output || [];
// 提取消息内容
let content = '';
for (const item of output) {
if (item.type === 'message' && item.content) {
for (const part of item.content) {
if (part.type === 'output_text') {
content += part.text || '';
}
}
}
}
const usage = response.usage || {};
return {
id: response.id || 'chatcmpl-' + Date.now(),
object: 'chat.completion',
created: Math.floor(Date.now() / 1000),
model: model,
choices: [{
index: 0,
message: {
role: 'assistant',
content: content
},
finish_reason: 'stop'
}],
usage: {
prompt_tokens: usage.input_tokens || 0,
completion_tokens: usage.output_tokens || 0,
total_tokens: usage.total_tokens || 0
}
};
} catch (e) {
throw new Error(`转换响应失败: ${e.message}`);
}
}
}
/**
* 处理流式请求
*/
async handleStreamRequest(req, res) {
try {
const openaiRequest = req.body;
console.log('收到请求:', JSON.stringify(openaiRequest, null, 2));
const codexRequest = this.transformRequest(openaiRequest);
console.log('转换后的 Codex 请求:', JSON.stringify(codexRequest, null, 2));
const accessToken = await this.tokenManager.getValidToken();
// 设置响应头
res.setHeader('Content-Type', 'text/event-stream');
res.setHeader('Cache-Control', 'no-cache');
res.setHeader('Connection', 'keep-alive');
const response = await axios.post(
`${CODEX_BASE_URL}/responses`,
codexRequest,
{
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'User-Agent': CODEX_USER_AGENT,
'Version': CODEX_CLIENT_VERSION,
'Openai-Beta': 'responses=experimental',
'Session_id': this.generateSessionId(),
'Accept': 'text/event-stream'
},
responseType: 'stream',
timeout: 300000 // 5 分钟超时
}
);
// 处理流式响应
let buffer = '';
const state = {}; // 用于保存响应 ID 和创建时间
response.data.on('data', (chunk) => {
buffer += chunk.toString();
const lines = buffer.split('\n');
// 保留最后一行(可能不完整)
buffer = lines.pop() || '';
for (const line of lines) {
if (line.trim()) {
const transformed = this.transformResponse(line, openaiRequest.model, true, state);
if (transformed) {
res.write(transformed);
}
}
}
});
response.data.on('end', () => {
// 处理缓冲区中剩余的数据
if (buffer.trim()) {
const transformed = this.transformResponse(buffer, openaiRequest.model, true, state);
if (transformed) {
res.write(transformed);
}
}
res.write('data: [DONE]\n\n');
res.end();
});
response.data.on('error', (error) => {
console.error('流式响应错误:', error.message);
res.end();
});
} catch (error) {
console.error('代理请求失败:', error.message);
if (error.response) {
console.error('响应状态:', error.response.status);
console.error('响应头:', error.response.headers);
// 尝试读取响应数据
if (error.response.data) {
if (typeof error.response.data === 'string') {
console.error('响应数据:', error.response.data);
} else if (error.response.data.on) {
// 如果是流,尝试读取
let data = '';
error.response.data.on('data', chunk => {
data += chunk.toString();
});
error.response.data.on('end', () => {
console.error('响应数据:', data);
});
} else {
try {
console.error('响应数据:', JSON.stringify(error.response.data));
} catch (e) {
console.error('响应数据类型:', typeof error.response.data);
}
}
}
}
if (!res.headersSent) {
res.status(error.response?.status || 500).json({
error: {
message: error.response?.data?.error?.message || error.message,
type: 'proxy_error',
code: error.response?.status || 500
}
});
}
}
}
/**
* 处理非流式请求
*/
async handleNonStreamRequest(req, res) {
try {
const openaiRequest = req.body;
console.log('收到请求:', JSON.stringify(openaiRequest, null, 2));
const codexRequest = this.transformRequest({ ...openaiRequest, stream: false });
console.log('转换后的 Codex 请求:', JSON.stringify(codexRequest, null, 2));
const accessToken = await this.tokenManager.getValidToken();
const response = await axios.post(
`${CODEX_BASE_URL}/responses`,
codexRequest,
{
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'User-Agent': CODEX_USER_AGENT,
'Version': CODEX_CLIENT_VERSION,
'Openai-Beta': 'responses=experimental',
'Session_id': this.generateSessionId()
},
timeout: 300000
}
);
// 处理响应数据 - 查找 response.completed 事件
let finalResponse = null;
const lines = response.data.split('\n');
for (const line of lines) {
if (line.trim().startsWith('data:')) {
const data = line.slice(5).trim();
try {
const parsed = JSON.parse(data);
if (parsed.type === 'response.completed') {
finalResponse = parsed;
break;
}
} catch (e) {
// 忽略解析错误
}
}
}
if (!finalResponse) {
throw new Error('未收到完整响应');
}
// 转换为 OpenAI 格式
const transformed = this.transformNonStreamResponse(finalResponse, openaiRequest.model);
res.json(transformed);
} catch (error) {
console.error('代理请求失败:', error.message);
if (error.response) {
console.error('响应状态:', error.response.status);
console.error('响应头:', error.response.headers);
try {
console.error('响应数据:', typeof error.response.data === 'string'
? error.response.data
: JSON.stringify(error.response.data));
} catch (e) {
console.error('响应数据无法序列化');
}
}
res.status(error.response?.status || 500).json({
error: {
message: error.response?.data?.error?.message || error.message,
type: 'proxy_error',
code: error.response?.status || 500
}
});
}
}
}
export default ProxyHandler;

132
src/tokenManager.js Normal file
View File

@@ -0,0 +1,132 @@
import fs from 'fs/promises';
import axios from 'axios';
// OpenAI OAuth 配置
const TOKEN_URL = 'https://auth.openai.com/oauth/token';
const CLIENT_ID = 'app_EMoamEEZ73f0CkXaXp7hrann';
/**
* Token 管理器
*/
class TokenManager {
constructor(tokenFilePath) {
this.tokenFilePath = tokenFilePath;
this.tokenData = null;
}
/**
* 从文件加载 token
*/
async loadToken() {
try {
const data = await fs.readFile(this.tokenFilePath, 'utf-8');
this.tokenData = JSON.parse(data);
console.log(`✓ Token 加载成功: ${this.tokenData.email || this.tokenData.account_id}`);
return this.tokenData;
} catch (error) {
throw new Error(`加载 token 文件失败: ${error.message}`);
}
}
/**
* 保存 token 到文件
*/
async saveToken(tokenData) {
try {
this.tokenData = tokenData;
await fs.writeFile(this.tokenFilePath, JSON.stringify(tokenData, null, 2), 'utf-8');
console.log('✓ Token 已保存到文件');
} catch (error) {
console.error(`保存 token 文件失败: ${error.message}`);
}
}
/**
* 检查 token 是否过期
*/
isTokenExpired() {
if (!this.tokenData || !this.tokenData.expired) {
return true;
}
const expireTime = new Date(this.tokenData.expired);
const now = new Date();
// 提前 5 分钟刷新
return expireTime.getTime() - now.getTime() < 5 * 60 * 1000;
}
/**
* 刷新 access token
*/
async refreshToken() {
if (!this.tokenData || !this.tokenData.refresh_token) {
throw new Error('没有可用的 refresh_token');
}
console.log('正在刷新 token...');
try {
const params = new URLSearchParams({
client_id: CLIENT_ID,
grant_type: 'refresh_token',
refresh_token: this.tokenData.refresh_token,
scope: 'openid profile email'
});
const response = await axios.post(TOKEN_URL, params.toString(), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
}
});
const { access_token, refresh_token, id_token, expires_in } = response.data;
// 更新 token 数据
const newTokenData = {
...this.tokenData,
access_token,
refresh_token: refresh_token || this.tokenData.refresh_token,
id_token: id_token || this.tokenData.id_token,
expired: new Date(Date.now() + expires_in * 1000).toISOString(),
last_refresh: new Date().toISOString()
};
await this.saveToken(newTokenData);
console.log('✓ Token 刷新成功');
return newTokenData;
} catch (error) {
const errorMsg = error.response?.data || error.message;
throw new Error(`Token 刷新失败: ${JSON.stringify(errorMsg)}`);
}
}
/**
* 获取有效的 access token自动刷新
*/
async getValidToken() {
if (!this.tokenData) {
await this.loadToken();
}
if (this.isTokenExpired()) {
await this.refreshToken();
}
return this.tokenData.access_token;
}
/**
* 获取 token 信息
*/
getTokenInfo() {
return {
email: this.tokenData?.email,
account_id: this.tokenData?.account_id,
expired: this.tokenData?.expired,
type: this.tokenData?.type
};
}
}
export default TokenManager;

10
token.example.json Normal file
View File

@@ -0,0 +1,10 @@
{
"id_token": "your_id_token_here",
"access_token": "your_access_token_here",
"refresh_token": "your_refresh_token_here",
"account_id": "your_account_id",
"email": "your_email@example.com",
"type": "codex",
"expired": "2026-12-31T23:59:59.000Z",
"last_refresh": "2026-01-01T00:00:00.000Z"
}