clash-linux commited on
Commit
5fa5930
·
verified ·
1 Parent(s): f3e2a2a

Upload 15 files

Browse files
.github/workflows/docker-publish.yml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Docker Image CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ build_and_push:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
14
+ packages: write
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Log in to the Container registry
21
+ uses: docker/login-action@v3
22
+ with:
23
+ registry: ghcr.io
24
+ username: ${{ github.repository_owner }}
25
+ password: ${{ secrets.GITHUB_TOKEN }}
26
+
27
+ - name: Build and push Docker image
28
+ uses: docker/build-push-action@v5
29
+ with:
30
+ context: .
31
+ push: true
32
+ tags: ghcr.io/${{ github.repository }}:latest
Dockerfile CHANGED
@@ -1,55 +1,28 @@
1
  # Use an official Node.js runtime as a parent image
2
  FROM node:18-slim
3
 
4
- # Switch to root user to install packages and configure system
5
- USER root
6
-
7
  # Set the working directory in the container
8
  WORKDIR /app
9
 
10
- # Install dependencies needed for traffic redirection and privilege drop
11
- # And clean up apt-get lists to keep the image slim
12
- RUN apt-get update && apt-get install -y --no-install-recommends \
13
- iptables \
14
- redsocks \
15
- gosu \
16
- && rm -rf /var/lib/apt/lists/*
17
-
18
  # Copy package.json and package-lock.json to the working directory
19
  COPY package*.json ./
20
 
21
  # Install app dependencies
22
- # Using --production flag to install only production dependencies
23
- # Playwright needs special handling to download browsers
24
- # We need to install dependencies first to make sure Playwright downloads its browsers.
25
  RUN npm install --production
26
 
27
  # Copy the rest of the application source code to the working directory
28
  COPY . .
29
 
30
- # Copy the configuration for redsocks
31
- COPY redsocks.conf /etc/redsocks.conf
32
-
33
- # Copy the entrypoint script
34
- COPY entrypoint.sh /app/entrypoint.sh
35
 
36
- # Grant execute permissions to scripts and the proxy binary
37
- RUN chmod +x /app/entrypoint.sh \
38
- && chmod +x /app/src/proxy/chrome_proxy_server_linux_amd64
39
-
40
- # Change ownership of the app directory to the node user
41
- RUN chown -R node:node /app
42
-
43
- # Switch to a non-root user for security
44
  USER node
45
 
46
  # Make port 7860 available to the world outside this container
47
  EXPOSE 7860
48
 
49
- # Set the entrypoint to our script.
50
- # This script will run as root to set up iptables.
51
- ENTRYPOINT ["/app/entrypoint.sh"]
52
-
53
- # Define the default command to run the app.
54
- # This will be executed by the entrypoint script using 'gosu' to drop to the 'node' user.
55
  CMD ["npm", "start"]
 
1
  # Use an official Node.js runtime as a parent image
2
  FROM node:18-slim
3
 
 
 
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
 
 
 
 
 
 
 
 
7
  # Copy package.json and package-lock.json to the working directory
8
  COPY package*.json ./
9
 
10
  # Install app dependencies
 
 
 
11
  RUN npm install --production
12
 
13
  # Copy the rest of the application source code to the working directory
14
  COPY . .
15
 
16
+ # Grant execute permission to the proxy server binary for the root user
17
+ # We keep this for now in case other parts of the app still reference it.
18
+ # We will remove it in a later step.
19
+ RUN chmod +x /app/src/proxy/chrome_proxy_server_linux_amd64
 
20
 
21
+ # Switch to a non-root user for security. This is a good practice.
 
 
 
 
 
 
 
22
  USER node
23
 
24
  # Make port 7860 available to the world outside this container
25
  EXPOSE 7860
26
 
27
+ # Define the command to run the app
 
 
 
 
 
28
  CMD ["npm", "start"]
package-lock.json CHANGED
@@ -13,6 +13,7 @@
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",
@@ -26,6 +27,33 @@
26
  "nodemon": "^3.0.2"
27
  }
28
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  "node_modules/@tootallnate/once": {
30
  "version": "2.0.0",
31
  "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
@@ -35,6 +63,11 @@
35
  "node": ">= 10"
36
  }
37
  },
 
 
 
 
 
38
  "node_modules/abab": {
39
  "version": "2.0.6",
40
  "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz",
@@ -55,6 +88,14 @@
55
  "node": ">= 0.6"
56
  }
57
  },
 
 
 
 
 
 
 
 
58
  "node_modules/agent-base": {
59
  "version": "7.1.3",
60
  "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
@@ -184,6 +225,37 @@
184
  "node": ">=8"
185
  }
186
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  "node_modules/bytes": {
188
  "version": "3.1.2",
189
  "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@@ -193,6 +265,31 @@
193
  "node": ">= 0.8"
194
  }
195
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  "node_modules/call-bind-apply-helpers": {
197
  "version": "1.0.2",
198
  "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
@@ -222,6 +319,36 @@
222
  "url": "https://github.com/sponsors/ljharb"
223
  }
224
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  "node_modules/chalk": {
226
  "version": "4.1.2",
227
  "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@@ -407,6 +534,39 @@
407
  "integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==",
408
  "license": "MIT"
409
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  "node_modules/delayed-stream": {
411
  "version": "1.0.0",
412
  "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@@ -448,6 +608,31 @@
448
  "node": ">=12"
449
  }
450
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  "node_modules/dotenv": {
452
  "version": "16.5.0",
453
  "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
@@ -480,6 +665,11 @@
480
  "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
481
  "license": "MIT"
482
  },
 
 
 
 
 
483
  "node_modules/encodeurl": {
484
  "version": "2.0.0",
485
  "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
@@ -546,6 +736,14 @@
546
  "node": ">= 0.4"
547
  }
548
  },
 
 
 
 
 
 
 
 
549
  "node_modules/escape-html": {
550
  "version": "1.0.3",
551
  "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
@@ -696,6 +894,14 @@
696
  "node": ">= 6"
697
  }
698
  },
 
 
 
 
 
 
 
 
699
  "node_modules/formdata-polyfill": {
700
  "version": "4.0.10",
701
  "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
@@ -750,6 +956,15 @@
750
  "url": "https://github.com/sponsors/ljharb"
751
  }
752
  },
 
 
 
 
 
 
 
 
 
753
  "node_modules/get-intrinsic": {
754
  "version": "1.3.0",
755
  "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
@@ -787,6 +1002,21 @@
787
  "node": ">= 0.4"
788
  }
789
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790
  "node_modules/glob-parent": {
791
  "version": "5.1.2",
792
  "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
@@ -812,6 +1042,47 @@
812
  "url": "https://github.com/sponsors/ljharb"
813
  }
814
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815
  "node_modules/has-flag": {
816
  "version": "3.0.0",
817
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@@ -861,6 +1132,71 @@
861
  "node": ">= 0.4"
862
  }
863
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
864
  "node_modules/html-encoding-sniffer": {
865
  "version": "3.0.0",
866
  "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
@@ -873,6 +1209,11 @@
873
  "node": ">=12"
874
  }
875
  },
 
 
 
 
 
876
  "node_modules/http-errors": {
877
  "version": "2.0.0",
878
  "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@@ -938,6 +1279,29 @@
938
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
939
  "license": "MIT"
940
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
941
  "node_modules/https-proxy-agent": {
942
  "version": "7.0.6",
943
  "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
@@ -1054,12 +1418,31 @@
1054
  "node": ">=0.12.0"
1055
  }
1056
  },
 
 
 
 
 
 
 
 
1057
  "node_modules/is-potential-custom-element-name": {
1058
  "version": "1.0.1",
1059
  "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
1060
  "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
1061
  "license": "MIT"
1062
  },
 
 
 
 
 
 
 
 
 
 
 
1063
  "node_modules/jsdom": {
1064
  "version": "22.1.0",
1065
  "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.1.0.tgz",
@@ -1150,6 +1533,36 @@
1150
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1151
  "license": "MIT"
1152
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1153
  "node_modules/math-intrinsics": {
1154
  "version": "1.1.0",
1155
  "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
@@ -1219,6 +1632,17 @@
1219
  "node": ">= 0.6"
1220
  }
1221
  },
 
 
 
 
 
 
 
 
 
 
 
1222
  "node_modules/minimatch": {
1223
  "version": "3.1.2",
1224
  "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
@@ -1285,6 +1709,11 @@
1285
  "url": "https://opencollective.com/node-fetch"
1286
  }
1287
  },
 
 
 
 
 
1288
  "node_modules/nodemon": {
1289
  "version": "3.1.10",
1290
  "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
@@ -1349,6 +1778,17 @@
1349
  "node": ">=0.10.0"
1350
  }
1351
  },
 
 
 
 
 
 
 
 
 
 
 
1352
  "node_modules/nwsapi": {
1353
  "version": "2.2.20",
1354
  "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.20.tgz",
@@ -1379,6 +1819,43 @@
1379
  "node": ">= 0.8"
1380
  }
1381
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1382
  "node_modules/parse5": {
1383
  "version": "7.3.0",
1384
  "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
@@ -1406,6 +1883,11 @@
1406
  "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
1407
  "license": "MIT"
1408
  },
 
 
 
 
 
1409
  "node_modules/picomatch": {
1410
  "version": "2.3.1",
1411
  "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
@@ -1531,6 +2013,17 @@
1531
  "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
1532
  "license": "MIT"
1533
  },
 
 
 
 
 
 
 
 
 
 
 
1534
  "node_modules/range-parser": {
1535
  "version": "1.2.1",
1536
  "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -1574,6 +2067,25 @@
1574
  "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
1575
  "license": "MIT"
1576
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1577
  "node_modules/rrweb-cssom": {
1578
  "version": "0.6.0",
1579
  "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz",
@@ -1863,6 +2375,11 @@
1863
  "node": ">=14"
1864
  }
1865
  },
 
 
 
 
 
1866
  "node_modules/tunnel": {
1867
  "version": "0.0.6",
1868
  "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
@@ -1871,6 +2388,17 @@
1871
  "node": ">=0.6.11 <=0.7.0 || >=0.7.3"
1872
  }
1873
  },
 
 
 
 
 
 
 
 
 
 
 
1874
  "node_modules/type-is": {
1875
  "version": "1.6.18",
1876
  "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
@@ -1909,6 +2437,35 @@
1909
  "node": ">= 0.8"
1910
  }
1911
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1912
  "node_modules/url-parse": {
1913
  "version": "1.5.10",
1914
  "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
@@ -1928,6 +2485,14 @@
1928
  "node": ">= 0.4.0"
1929
  }
1930
  },
 
 
 
 
 
 
 
 
1931
  "node_modules/vary": {
1932
  "version": "1.1.2",
1933
  "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
 
13
  "chalk": "^4.1.2",
14
  "dotenv": "^16.3.1",
15
  "express": "^4.18.2",
16
+ "got-scraping": "^4.1.1",
17
  "https-proxy-agent": "^7.0.2",
18
  "jsdom": "^22.1.0",
19
  "node-fetch": "^3.3.2",
 
27
  "nodemon": "^3.0.2"
28
  }
29
  },
30
+ "node_modules/@sec-ant/readable-stream": {
31
+ "version": "0.4.1",
32
+ "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz",
33
+ "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg=="
34
+ },
35
+ "node_modules/@sindresorhus/is": {
36
+ "version": "7.0.2",
37
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.0.2.tgz",
38
+ "integrity": "sha512-d9xRovfKNz1SKieM0qJdO+PQonjnnIfSNWfHYnBSJ9hkjm0ZPw6HlxscDXYstp3z+7V2GOFHc+J0CYrYTjqCJw==",
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "funding": {
43
+ "url": "https://github.com/sindresorhus/is?sponsor=1"
44
+ }
45
+ },
46
+ "node_modules/@szmarczak/http-timer": {
47
+ "version": "5.0.1",
48
+ "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz",
49
+ "integrity": "sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==",
50
+ "dependencies": {
51
+ "defer-to-connect": "^2.0.1"
52
+ },
53
+ "engines": {
54
+ "node": ">=14.16"
55
+ }
56
+ },
57
  "node_modules/@tootallnate/once": {
58
  "version": "2.0.0",
59
  "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
 
63
  "node": ">= 10"
64
  }
65
  },
66
+ "node_modules/@types/http-cache-semantics": {
67
+ "version": "4.0.4",
68
+ "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
69
+ "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA=="
70
+ },
71
  "node_modules/abab": {
72
  "version": "2.0.6",
73
  "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz",
 
88
  "node": ">= 0.6"
89
  }
90
  },
91
+ "node_modules/adm-zip": {
92
+ "version": "0.5.16",
93
+ "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.16.tgz",
94
+ "integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==",
95
+ "engines": {
96
+ "node": ">=12.0"
97
+ }
98
+ },
99
  "node_modules/agent-base": {
100
  "version": "7.1.3",
101
  "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
 
225
  "node": ">=8"
226
  }
227
  },
228
+ "node_modules/browserslist": {
229
+ "version": "4.25.0",
230
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.25.0.tgz",
231
+ "integrity": "sha512-PJ8gYKeS5e/whHBh8xrwYK+dAvEj7JXtz6uTucnMRB8OiGTsKccFekoRrjajPBHV8oOY+2tI4uxeceSimKwMFA==",
232
+ "funding": [
233
+ {
234
+ "type": "opencollective",
235
+ "url": "https://opencollective.com/browserslist"
236
+ },
237
+ {
238
+ "type": "tidelift",
239
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
240
+ },
241
+ {
242
+ "type": "github",
243
+ "url": "https://github.com/sponsors/ai"
244
+ }
245
+ ],
246
+ "dependencies": {
247
+ "caniuse-lite": "^1.0.30001718",
248
+ "electron-to-chromium": "^1.5.160",
249
+ "node-releases": "^2.0.19",
250
+ "update-browserslist-db": "^1.1.3"
251
+ },
252
+ "bin": {
253
+ "browserslist": "cli.js"
254
+ },
255
+ "engines": {
256
+ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
257
+ }
258
+ },
259
  "node_modules/bytes": {
260
  "version": "3.1.2",
261
  "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
 
265
  "node": ">= 0.8"
266
  }
267
  },
268
+ "node_modules/cacheable-lookup": {
269
+ "version": "7.0.0",
270
+ "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz",
271
+ "integrity": "sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==",
272
+ "engines": {
273
+ "node": ">=14.16"
274
+ }
275
+ },
276
+ "node_modules/cacheable-request": {
277
+ "version": "12.0.1",
278
+ "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-12.0.1.tgz",
279
+ "integrity": "sha512-Yo9wGIQUaAfIbk+qY0X4cDQgCosecfBe3V9NSyeY4qPC2SAkbCS4Xj79VP8WOzitpJUZKc/wsRCYF5ariDIwkg==",
280
+ "dependencies": {
281
+ "@types/http-cache-semantics": "^4.0.4",
282
+ "get-stream": "^9.0.1",
283
+ "http-cache-semantics": "^4.1.1",
284
+ "keyv": "^4.5.4",
285
+ "mimic-response": "^4.0.0",
286
+ "normalize-url": "^8.0.1",
287
+ "responselike": "^3.0.0"
288
+ },
289
+ "engines": {
290
+ "node": ">=18"
291
+ }
292
+ },
293
  "node_modules/call-bind-apply-helpers": {
294
  "version": "1.0.2",
295
  "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
 
319
  "url": "https://github.com/sponsors/ljharb"
320
  }
321
  },
322
+ "node_modules/callsites": {
323
+ "version": "4.2.0",
324
+ "resolved": "https://registry.npmjs.org/callsites/-/callsites-4.2.0.tgz",
325
+ "integrity": "sha512-kfzR4zzQtAE9PC7CzZsjl3aBNbXWuXiSeOCdLcPpBfGW8YuCqQHcRPFDbr/BPVmd3EEPVpuFzLyuT/cUhPr4OQ==",
326
+ "engines": {
327
+ "node": ">=12.20"
328
+ },
329
+ "funding": {
330
+ "url": "https://github.com/sponsors/sindresorhus"
331
+ }
332
+ },
333
+ "node_modules/caniuse-lite": {
334
+ "version": "1.0.30001722",
335
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001722.tgz",
336
+ "integrity": "sha512-DCQHBBZtiK6JVkAGw7drvAMK0Q0POD/xZvEmDp6baiMMP6QXXk9HpD6mNYBZWhOPG6LvIDb82ITqtWjhDckHCA==",
337
+ "funding": [
338
+ {
339
+ "type": "opencollective",
340
+ "url": "https://opencollective.com/browserslist"
341
+ },
342
+ {
343
+ "type": "tidelift",
344
+ "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
345
+ },
346
+ {
347
+ "type": "github",
348
+ "url": "https://github.com/sponsors/ai"
349
+ }
350
+ ]
351
+ },
352
  "node_modules/chalk": {
353
  "version": "4.1.2",
354
  "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
 
534
  "integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==",
535
  "license": "MIT"
536
  },
537
+ "node_modules/decompress-response": {
538
+ "version": "6.0.0",
539
+ "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
540
+ "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
541
+ "dependencies": {
542
+ "mimic-response": "^3.1.0"
543
+ },
544
+ "engines": {
545
+ "node": ">=10"
546
+ },
547
+ "funding": {
548
+ "url": "https://github.com/sponsors/sindresorhus"
549
+ }
550
+ },
551
+ "node_modules/decompress-response/node_modules/mimic-response": {
552
+ "version": "3.1.0",
553
+ "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
554
+ "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==",
555
+ "engines": {
556
+ "node": ">=10"
557
+ },
558
+ "funding": {
559
+ "url": "https://github.com/sponsors/sindresorhus"
560
+ }
561
+ },
562
+ "node_modules/defer-to-connect": {
563
+ "version": "2.0.1",
564
+ "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz",
565
+ "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==",
566
+ "engines": {
567
+ "node": ">=10"
568
+ }
569
+ },
570
  "node_modules/delayed-stream": {
571
  "version": "1.0.0",
572
  "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
 
608
  "node": ">=12"
609
  }
610
  },
611
+ "node_modules/dot-prop": {
612
+ "version": "7.2.0",
613
+ "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-7.2.0.tgz",
614
+ "integrity": "sha512-Ol/IPXUARn9CSbkrdV4VJo7uCy1I3VuSiWCaFSg+8BdUOzF9n3jefIpcgAydvUZbTdEBZs2vEiTiS9m61ssiDA==",
615
+ "dependencies": {
616
+ "type-fest": "^2.11.2"
617
+ },
618
+ "engines": {
619
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
620
+ },
621
+ "funding": {
622
+ "url": "https://github.com/sponsors/sindresorhus"
623
+ }
624
+ },
625
+ "node_modules/dot-prop/node_modules/type-fest": {
626
+ "version": "2.19.0",
627
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz",
628
+ "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==",
629
+ "engines": {
630
+ "node": ">=12.20"
631
+ },
632
+ "funding": {
633
+ "url": "https://github.com/sponsors/sindresorhus"
634
+ }
635
+ },
636
  "node_modules/dotenv": {
637
  "version": "16.5.0",
638
  "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
 
665
  "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
666
  "license": "MIT"
667
  },
668
+ "node_modules/electron-to-chromium": {
669
+ "version": "1.5.166",
670
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.166.tgz",
671
+ "integrity": "sha512-QPWqHL0BglzPYyJJ1zSSmwFFL6MFXhbACOCcsCdUMCkzPdS9/OIBVxg516X/Ado2qwAq8k0nJJ7phQPCqiaFAw=="
672
+ },
673
  "node_modules/encodeurl": {
674
  "version": "2.0.0",
675
  "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
 
736
  "node": ">= 0.4"
737
  }
738
  },
739
+ "node_modules/escalade": {
740
+ "version": "3.2.0",
741
+ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
742
+ "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
743
+ "engines": {
744
+ "node": ">=6"
745
+ }
746
+ },
747
  "node_modules/escape-html": {
748
  "version": "1.0.3",
749
  "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
 
894
  "node": ">= 6"
895
  }
896
  },
897
+ "node_modules/form-data-encoder": {
898
+ "version": "4.1.0",
899
+ "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-4.1.0.tgz",
900
+ "integrity": "sha512-G6NsmEW15s0Uw9XnCg+33H3ViYRyiM0hMrMhhqQOR8NFc5GhYrI+6I3u7OTw7b91J2g8rtvMBZJDbcGb2YUniw==",
901
+ "engines": {
902
+ "node": ">= 18"
903
+ }
904
+ },
905
  "node_modules/formdata-polyfill": {
906
  "version": "4.0.10",
907
  "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
 
956
  "url": "https://github.com/sponsors/ljharb"
957
  }
958
  },
959
+ "node_modules/generative-bayesian-network": {
960
+ "version": "2.1.66",
961
+ "resolved": "https://registry.npmjs.org/generative-bayesian-network/-/generative-bayesian-network-2.1.66.tgz",
962
+ "integrity": "sha512-gbBsyaaEJj/LHp3473TQrMDdcKiRzI8Sn2CbcG/lwONZkp0n9/ChC1mjzcbZQtHHCuqjn+JouSSbzLeepUMbuw==",
963
+ "dependencies": {
964
+ "adm-zip": "^0.5.9",
965
+ "tslib": "^2.4.0"
966
+ }
967
+ },
968
  "node_modules/get-intrinsic": {
969
  "version": "1.3.0",
970
  "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
 
1002
  "node": ">= 0.4"
1003
  }
1004
  },
1005
+ "node_modules/get-stream": {
1006
+ "version": "9.0.1",
1007
+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz",
1008
+ "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==",
1009
+ "dependencies": {
1010
+ "@sec-ant/readable-stream": "^0.4.1",
1011
+ "is-stream": "^4.0.1"
1012
+ },
1013
+ "engines": {
1014
+ "node": ">=18"
1015
+ },
1016
+ "funding": {
1017
+ "url": "https://github.com/sponsors/sindresorhus"
1018
+ }
1019
+ },
1020
  "node_modules/glob-parent": {
1021
  "version": "5.1.2",
1022
  "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
 
1042
  "url": "https://github.com/sponsors/ljharb"
1043
  }
1044
  },
1045
+ "node_modules/got": {
1046
+ "version": "14.4.7",
1047
+ "resolved": "https://registry.npmjs.org/got/-/got-14.4.7.tgz",
1048
+ "integrity": "sha512-DI8zV1231tqiGzOiOzQWDhsBmncFW7oQDH6Zgy6pDPrqJuVZMtoSgPLLsBZQj8Jg4JFfwoOsDA8NGtLQLnIx2g==",
1049
+ "dependencies": {
1050
+ "@sindresorhus/is": "^7.0.1",
1051
+ "@szmarczak/http-timer": "^5.0.1",
1052
+ "cacheable-lookup": "^7.0.0",
1053
+ "cacheable-request": "^12.0.1",
1054
+ "decompress-response": "^6.0.0",
1055
+ "form-data-encoder": "^4.0.2",
1056
+ "http2-wrapper": "^2.2.1",
1057
+ "lowercase-keys": "^3.0.0",
1058
+ "p-cancelable": "^4.0.1",
1059
+ "responselike": "^3.0.0",
1060
+ "type-fest": "^4.26.1"
1061
+ },
1062
+ "engines": {
1063
+ "node": ">=20"
1064
+ },
1065
+ "funding": {
1066
+ "url": "https://github.com/sindresorhus/got?sponsor=1"
1067
+ }
1068
+ },
1069
+ "node_modules/got-scraping": {
1070
+ "version": "4.1.1",
1071
+ "resolved": "https://registry.npmjs.org/got-scraping/-/got-scraping-4.1.1.tgz",
1072
+ "integrity": "sha512-MbT+NMMU4VgvOg2tFIPOSIrMfH986fm0LJ17RxBLKlyTs3gh3xIMETpe+zdPaXY7tH1j6YYeqtfG0TnVMx6V2g==",
1073
+ "dependencies": {
1074
+ "got": "^14.2.1",
1075
+ "header-generator": "^2.1.41",
1076
+ "http2-wrapper": "^2.2.0",
1077
+ "mimic-response": "^4.0.0",
1078
+ "ow": "^1.1.1",
1079
+ "quick-lru": "^7.0.0",
1080
+ "tslib": "^2.6.2"
1081
+ },
1082
+ "engines": {
1083
+ "node": ">=16"
1084
+ }
1085
+ },
1086
  "node_modules/has-flag": {
1087
  "version": "3.0.0",
1088
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
 
1132
  "node": ">= 0.4"
1133
  }
1134
  },
1135
+ "node_modules/header-generator": {
1136
+ "version": "2.1.66",
1137
+ "resolved": "https://registry.npmjs.org/header-generator/-/header-generator-2.1.66.tgz",
1138
+ "integrity": "sha512-g0jd79o0CyzyK0Jega4pAG1eJhykhPNfBLpOnUINtX2YkToVvRSBZ+B2wtmIjqwKHXK8DNWxylKuXnZmLs1yMQ==",
1139
+ "dependencies": {
1140
+ "browserslist": "^4.21.1",
1141
+ "generative-bayesian-network": "^2.1.66",
1142
+ "ow": "^0.28.1",
1143
+ "tslib": "^2.4.0"
1144
+ },
1145
+ "engines": {
1146
+ "node": ">=16.0.0"
1147
+ }
1148
+ },
1149
+ "node_modules/header-generator/node_modules/@sindresorhus/is": {
1150
+ "version": "4.6.0",
1151
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz",
1152
+ "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==",
1153
+ "engines": {
1154
+ "node": ">=10"
1155
+ },
1156
+ "funding": {
1157
+ "url": "https://github.com/sindresorhus/is?sponsor=1"
1158
+ }
1159
+ },
1160
+ "node_modules/header-generator/node_modules/callsites": {
1161
+ "version": "3.1.0",
1162
+ "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
1163
+ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
1164
+ "engines": {
1165
+ "node": ">=6"
1166
+ }
1167
+ },
1168
+ "node_modules/header-generator/node_modules/dot-prop": {
1169
+ "version": "6.0.1",
1170
+ "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz",
1171
+ "integrity": "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==",
1172
+ "dependencies": {
1173
+ "is-obj": "^2.0.0"
1174
+ },
1175
+ "engines": {
1176
+ "node": ">=10"
1177
+ },
1178
+ "funding": {
1179
+ "url": "https://github.com/sponsors/sindresorhus"
1180
+ }
1181
+ },
1182
+ "node_modules/header-generator/node_modules/ow": {
1183
+ "version": "0.28.2",
1184
+ "resolved": "https://registry.npmjs.org/ow/-/ow-0.28.2.tgz",
1185
+ "integrity": "sha512-dD4UpyBh/9m4X2NVjA+73/ZPBRF+uF4zIMFvvQsabMiEK8x41L3rQ8EENOi35kyyoaJwNxEeJcP6Fj1H4U409Q==",
1186
+ "dependencies": {
1187
+ "@sindresorhus/is": "^4.2.0",
1188
+ "callsites": "^3.1.0",
1189
+ "dot-prop": "^6.0.1",
1190
+ "lodash.isequal": "^4.5.0",
1191
+ "vali-date": "^1.0.0"
1192
+ },
1193
+ "engines": {
1194
+ "node": ">=12"
1195
+ },
1196
+ "funding": {
1197
+ "url": "https://github.com/sponsors/sindresorhus"
1198
+ }
1199
+ },
1200
  "node_modules/html-encoding-sniffer": {
1201
  "version": "3.0.0",
1202
  "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
 
1209
  "node": ">=12"
1210
  }
1211
  },
1212
+ "node_modules/http-cache-semantics": {
1213
+ "version": "4.2.0",
1214
+ "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz",
1215
+ "integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ=="
1216
+ },
1217
  "node_modules/http-errors": {
1218
  "version": "2.0.0",
1219
  "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
 
1279
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1280
  "license": "MIT"
1281
  },
1282
+ "node_modules/http2-wrapper": {
1283
+ "version": "2.2.1",
1284
+ "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-2.2.1.tgz",
1285
+ "integrity": "sha512-V5nVw1PAOgfI3Lmeaj2Exmeg7fenjhRUgz1lPSezy1CuhPYbgQtbQj4jZfEAEMlaL+vupsvhjqCyjzob0yxsmQ==",
1286
+ "dependencies": {
1287
+ "quick-lru": "^5.1.1",
1288
+ "resolve-alpn": "^1.2.0"
1289
+ },
1290
+ "engines": {
1291
+ "node": ">=10.19.0"
1292
+ }
1293
+ },
1294
+ "node_modules/http2-wrapper/node_modules/quick-lru": {
1295
+ "version": "5.1.1",
1296
+ "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
1297
+ "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==",
1298
+ "engines": {
1299
+ "node": ">=10"
1300
+ },
1301
+ "funding": {
1302
+ "url": "https://github.com/sponsors/sindresorhus"
1303
+ }
1304
+ },
1305
  "node_modules/https-proxy-agent": {
1306
  "version": "7.0.6",
1307
  "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
 
1418
  "node": ">=0.12.0"
1419
  }
1420
  },
1421
+ "node_modules/is-obj": {
1422
+ "version": "2.0.0",
1423
+ "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
1424
+ "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
1425
+ "engines": {
1426
+ "node": ">=8"
1427
+ }
1428
+ },
1429
  "node_modules/is-potential-custom-element-name": {
1430
  "version": "1.0.1",
1431
  "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
1432
  "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
1433
  "license": "MIT"
1434
  },
1435
+ "node_modules/is-stream": {
1436
+ "version": "4.0.1",
1437
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz",
1438
+ "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==",
1439
+ "engines": {
1440
+ "node": ">=18"
1441
+ },
1442
+ "funding": {
1443
+ "url": "https://github.com/sponsors/sindresorhus"
1444
+ }
1445
+ },
1446
  "node_modules/jsdom": {
1447
  "version": "22.1.0",
1448
  "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.1.0.tgz",
 
1533
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1534
  "license": "MIT"
1535
  },
1536
+ "node_modules/json-buffer": {
1537
+ "version": "3.0.1",
1538
+ "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
1539
+ "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
1540
+ },
1541
+ "node_modules/keyv": {
1542
+ "version": "4.5.4",
1543
+ "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
1544
+ "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==",
1545
+ "dependencies": {
1546
+ "json-buffer": "3.0.1"
1547
+ }
1548
+ },
1549
+ "node_modules/lodash.isequal": {
1550
+ "version": "4.5.0",
1551
+ "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
1552
+ "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
1553
+ "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead."
1554
+ },
1555
+ "node_modules/lowercase-keys": {
1556
+ "version": "3.0.0",
1557
+ "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz",
1558
+ "integrity": "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==",
1559
+ "engines": {
1560
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
1561
+ },
1562
+ "funding": {
1563
+ "url": "https://github.com/sponsors/sindresorhus"
1564
+ }
1565
+ },
1566
  "node_modules/math-intrinsics": {
1567
  "version": "1.1.0",
1568
  "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
 
1632
  "node": ">= 0.6"
1633
  }
1634
  },
1635
+ "node_modules/mimic-response": {
1636
+ "version": "4.0.0",
1637
+ "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-4.0.0.tgz",
1638
+ "integrity": "sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==",
1639
+ "engines": {
1640
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
1641
+ },
1642
+ "funding": {
1643
+ "url": "https://github.com/sponsors/sindresorhus"
1644
+ }
1645
+ },
1646
  "node_modules/minimatch": {
1647
  "version": "3.1.2",
1648
  "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
 
1709
  "url": "https://opencollective.com/node-fetch"
1710
  }
1711
  },
1712
+ "node_modules/node-releases": {
1713
+ "version": "2.0.19",
1714
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz",
1715
+ "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw=="
1716
+ },
1717
  "node_modules/nodemon": {
1718
  "version": "3.1.10",
1719
  "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
 
1778
  "node": ">=0.10.0"
1779
  }
1780
  },
1781
+ "node_modules/normalize-url": {
1782
+ "version": "8.0.2",
1783
+ "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-8.0.2.tgz",
1784
+ "integrity": "sha512-Ee/R3SyN4BuynXcnTaekmaVdbDAEiNrHqjQIA37mHU8G9pf7aaAD4ZX3XjBLo6rsdcxA/gtkcNYZLt30ACgynw==",
1785
+ "engines": {
1786
+ "node": ">=14.16"
1787
+ },
1788
+ "funding": {
1789
+ "url": "https://github.com/sponsors/sindresorhus"
1790
+ }
1791
+ },
1792
  "node_modules/nwsapi": {
1793
  "version": "2.2.20",
1794
  "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.20.tgz",
 
1819
  "node": ">= 0.8"
1820
  }
1821
  },
1822
+ "node_modules/ow": {
1823
+ "version": "1.1.1",
1824
+ "resolved": "https://registry.npmjs.org/ow/-/ow-1.1.1.tgz",
1825
+ "integrity": "sha512-sJBRCbS5vh1Jp9EOgwp1Ws3c16lJrUkJYlvWTYC03oyiYVwS/ns7lKRWow4w4XjDyTrA2pplQv4B2naWSR6yDA==",
1826
+ "dependencies": {
1827
+ "@sindresorhus/is": "^5.3.0",
1828
+ "callsites": "^4.0.0",
1829
+ "dot-prop": "^7.2.0",
1830
+ "lodash.isequal": "^4.5.0",
1831
+ "vali-date": "^1.0.0"
1832
+ },
1833
+ "engines": {
1834
+ "node": ">=14.16"
1835
+ },
1836
+ "funding": {
1837
+ "url": "https://github.com/sponsors/sindresorhus"
1838
+ }
1839
+ },
1840
+ "node_modules/ow/node_modules/@sindresorhus/is": {
1841
+ "version": "5.6.0",
1842
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-5.6.0.tgz",
1843
+ "integrity": "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==",
1844
+ "engines": {
1845
+ "node": ">=14.16"
1846
+ },
1847
+ "funding": {
1848
+ "url": "https://github.com/sindresorhus/is?sponsor=1"
1849
+ }
1850
+ },
1851
+ "node_modules/p-cancelable": {
1852
+ "version": "4.0.1",
1853
+ "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-4.0.1.tgz",
1854
+ "integrity": "sha512-wBowNApzd45EIKdO1LaU+LrMBwAcjfPaYtVzV3lmfM3gf8Z4CHZsiIqlM8TZZ8okYvh5A1cP6gTfCRQtwUpaUg==",
1855
+ "engines": {
1856
+ "node": ">=14.16"
1857
+ }
1858
+ },
1859
  "node_modules/parse5": {
1860
  "version": "7.3.0",
1861
  "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
 
1883
  "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
1884
  "license": "MIT"
1885
  },
1886
+ "node_modules/picocolors": {
1887
+ "version": "1.1.1",
1888
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
1889
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
1890
+ },
1891
  "node_modules/picomatch": {
1892
  "version": "2.3.1",
1893
  "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
 
2013
  "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
2014
  "license": "MIT"
2015
  },
2016
+ "node_modules/quick-lru": {
2017
+ "version": "7.0.1",
2018
+ "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-7.0.1.tgz",
2019
+ "integrity": "sha512-kLjThirJMkWKutUKbZ8ViqFc09tDQhlbQo2MNuVeLWbRauqYP96Sm6nzlQ24F0HFjUNZ4i9+AgldJ9H6DZXi7g==",
2020
+ "engines": {
2021
+ "node": ">=18"
2022
+ },
2023
+ "funding": {
2024
+ "url": "https://github.com/sponsors/sindresorhus"
2025
+ }
2026
+ },
2027
  "node_modules/range-parser": {
2028
  "version": "1.2.1",
2029
  "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
 
2067
  "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
2068
  "license": "MIT"
2069
  },
2070
+ "node_modules/resolve-alpn": {
2071
+ "version": "1.2.1",
2072
+ "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
2073
+ "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g=="
2074
+ },
2075
+ "node_modules/responselike": {
2076
+ "version": "3.0.0",
2077
+ "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz",
2078
+ "integrity": "sha512-40yHxbNcl2+rzXvZuVkrYohathsSJlMTXKryG5y8uciHv1+xDLHQpgjG64JUO9nrEq2jGLH6IZ8BcZyw3wrweg==",
2079
+ "dependencies": {
2080
+ "lowercase-keys": "^3.0.0"
2081
+ },
2082
+ "engines": {
2083
+ "node": ">=14.16"
2084
+ },
2085
+ "funding": {
2086
+ "url": "https://github.com/sponsors/sindresorhus"
2087
+ }
2088
+ },
2089
  "node_modules/rrweb-cssom": {
2090
  "version": "0.6.0",
2091
  "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz",
 
2375
  "node": ">=14"
2376
  }
2377
  },
2378
+ "node_modules/tslib": {
2379
+ "version": "2.8.1",
2380
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
2381
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
2382
+ },
2383
  "node_modules/tunnel": {
2384
  "version": "0.0.6",
2385
  "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
 
2388
  "node": ">=0.6.11 <=0.7.0 || >=0.7.3"
2389
  }
2390
  },
2391
+ "node_modules/type-fest": {
2392
+ "version": "4.41.0",
2393
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz",
2394
+ "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==",
2395
+ "engines": {
2396
+ "node": ">=16"
2397
+ },
2398
+ "funding": {
2399
+ "url": "https://github.com/sponsors/sindresorhus"
2400
+ }
2401
+ },
2402
  "node_modules/type-is": {
2403
  "version": "1.6.18",
2404
  "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
 
2437
  "node": ">= 0.8"
2438
  }
2439
  },
2440
+ "node_modules/update-browserslist-db": {
2441
+ "version": "1.1.3",
2442
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz",
2443
+ "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==",
2444
+ "funding": [
2445
+ {
2446
+ "type": "opencollective",
2447
+ "url": "https://opencollective.com/browserslist"
2448
+ },
2449
+ {
2450
+ "type": "tidelift",
2451
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
2452
+ },
2453
+ {
2454
+ "type": "github",
2455
+ "url": "https://github.com/sponsors/ai"
2456
+ }
2457
+ ],
2458
+ "dependencies": {
2459
+ "escalade": "^3.2.0",
2460
+ "picocolors": "^1.1.1"
2461
+ },
2462
+ "bin": {
2463
+ "update-browserslist-db": "cli.js"
2464
+ },
2465
+ "peerDependencies": {
2466
+ "browserslist": ">= 4.21.0"
2467
+ }
2468
+ },
2469
  "node_modules/url-parse": {
2470
  "version": "1.5.10",
2471
  "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
 
2485
  "node": ">= 0.4.0"
2486
  }
2487
  },
2488
+ "node_modules/vali-date": {
2489
+ "version": "1.0.0",
2490
+ "resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz",
2491
+ "integrity": "sha512-sgECfZthyaCKW10N0fm27cg8HYTFK5qMWgypqkXMQ4Wbl/zZKx7xZICgcoxIIE+WFAP/MBL2EFwC/YvLxw3Zeg==",
2492
+ "engines": {
2493
+ "node": ">=0.10.0"
2494
+ }
2495
+ },
2496
  "node_modules/vary": {
2497
  "version": "1.1.2",
2498
  "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
package.json CHANGED
@@ -26,6 +26,7 @@
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",
31
  "node-fetch": "^3.3.2",
 
26
  "chalk": "^4.1.2",
27
  "dotenv": "^16.3.1",
28
  "express": "^4.18.2",
29
+ "got-scraping": "^4.1.1",
30
  "https-proxy-agent": "^7.0.2",
31
  "jsdom": "^22.1.0",
32
  "node-fetch": "^3.3.2",
src/lightweight-client.js CHANGED
@@ -14,6 +14,7 @@ import {
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);
@@ -227,460 +228,82 @@ async function streamNotionResponse(notionRequestBody) {
227
  const timeoutId = setTimeout(() => {
228
  logger.warning(`请求超时,30秒内未收到响应`);
229
  try {
230
- // 发送结束消息
231
- const endChunk = new ChatCompletionChunk({
232
- choices: [
233
- new Choice({
234
- delta: new ChoiceDelta({ content: "请求超时,未收到Notion响应。" }),
235
- finish_reason: "timeout"
236
- })
237
- ]
238
- });
239
- stream.write(`data: ${JSON.stringify(endChunk)}\n\n`);
240
- stream.write('data: [DONE]\n\n');
241
- stream.end();
242
- } catch (error) {
243
- logger.error(`发送超时消息时出错: ${error}`);
244
- stream.end();
245
- }
246
- }, 30000); // 30秒超时
247
-
248
- // 启动fetch处理
249
- fetchNotionResponse(
250
- stream,
251
- notionRequestBody,
252
- headers,
253
- NOTION_API_URL,
254
- currentCookieData.cookie,
255
- timeoutId
256
- ).catch((error) => {
257
- logger.error(`流处理出错: ${error}`);
258
- clearTimeout(timeoutId); // 清除超时计时器
259
-
260
- try {
261
- // 发送错误消息
262
- const errorChunk = new ChatCompletionChunk({
263
- choices: [
264
- new Choice({
265
- delta: new ChoiceDelta({ content: `处理请求时出错: ${error.message}` }),
266
- finish_reason: "error"
267
- })
268
- ]
269
- });
270
- stream.write(`data: ${JSON.stringify(errorChunk)}\n\n`);
271
- stream.write('data: [DONE]\n\n');
272
  } catch (e) {
273
- logger.error(`发送错误消息时出错: ${e}`);
274
- } finally {
275
- stream.end();
276
  }
277
- });
278
-
279
- return stream;
280
- }
281
 
282
- // 使用fetch调用Notion API并处理流式响应
283
- async function fetchNotionResponse(chunkQueue, notionRequestBody, headers, notionApiUrl, notionCookie, timeoutId) {
284
  let responseReceived = false;
285
- let dom = null;
286
 
287
  try {
288
- // 创建JSDOM实例模拟浏览器环境
289
- dom = new JSDOM("", {
290
- url: "https://www.notion.so",
291
- referrer: "https://www.notion.so/chat",
292
- contentType: "text/html",
293
- includeNodeLocations: true,
294
- storageQuota: 10000000,
295
- pretendToBeVisual: true,
296
- userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"
297
- });
298
-
299
- // 设置全局对象
300
- const { window } = dom;
301
-
302
- // 使用更安全的方式设置全局对象
303
- try {
304
- if (!global.window) {
305
- global.window = window;
306
- }
307
-
308
- if (!global.document) {
309
- global.document = window.document;
310
- }
311
-
312
- // 安全地设置navigator
313
- if (!global.navigator) {
314
- try {
315
- Object.defineProperty(global, 'navigator', {
316
- value: window.navigator,
317
- writable: true,
318
- configurable: true
319
- });
320
- } catch (navError) {
321
- logger.warning(`无法设置navigator: ${navError.message},继续执行`);
322
- // 继续执行,不会中断流程
323
- }
324
- }
325
- } catch (globalError) {
326
- logger.warning(`设置全局对象时出错: ${globalError.message}`);
327
- }
328
-
329
- // 设置cookie
330
- document.cookie = notionCookie;
331
-
332
- // 创建fetch选项
333
- const fetchOptions = {
334
  method: 'POST',
335
- headers: {
336
- ...headers,
337
- 'user-agent': window.navigator.userAgent,
338
- 'Cookie': notionCookie
339
- },
340
  body: JSON.stringify(notionRequestBody),
 
 
 
 
 
 
 
 
 
 
341
  };
342
-
343
- // 添加代理配置(如果有)
344
- if (USE_NATIVE_PROXY_POOL) {
345
- proxy = proxyPool.getProxy();
346
- if (proxy !== null)
347
- {
348
- const { HttpsProxyAgent } = await import('https-proxy-agent');
349
- fetchOptions.agent = new HttpsProxyAgent(proxy.full);
350
- logger.info(`使用代理: ${proxy.full}`);
351
- }
352
- else{
353
- logger.warning(`没有可用代理`);
354
- }
355
- } else if(PROXY_URL) {
356
- const { HttpsProxyAgent } = await import('https-proxy-agent');
357
- fetchOptions.agent = new HttpsProxyAgent(PROXY_URL);
358
  logger.info(`使用代理: ${PROXY_URL}`);
359
  }
360
- let response = null;
361
- // 发送请求
362
- if (ENABLE_PROXY_SERVER){
363
- response = await fetch('http://127.0.0.1:10655/proxy', {
364
- method: 'POST',
365
- body: JSON.stringify({
366
- method: 'POST',
367
- url: notionApiUrl,
368
- headers: fetchOptions.headers,
369
- body: fetchOptions.body,
370
- stream:true
371
- }),
372
- });
373
- }else{
374
- response = await fetch(notionApiUrl, fetchOptions);
375
- }
376
 
377
- // 检查是否收到401错误(未授权)
378
- if (response.status === 401) {
379
- logger.error(`收到401未授权错误,cookie可能已失效`);
380
- // 标记当前cookie为无效
381
- cookieManager.markAsInvalid(currentCookieData.userId);
382
- // 尝试获取下一个cookie
383
- currentCookieData = cookieManager.getNext();
384
-
385
- if (!currentCookieData) {
386
- throw new Error('所有cookie均已失效,无法继续请求');
387
- }
388
-
389
- // 使用新cookie重新构建请求体
390
- const newRequestBody = buildNotionRequest({
391
- model: notionRequestBody.transcript[0]?.value?.model || '',
392
- messages: [] // 这里应该根据实际情况重构消息
393
- });
394
-
395
- // 使用新cookie重试请求
396
- return fetchNotionResponse(
397
- chunkQueue,
398
- newRequestBody,
399
- {
400
- ...headers,
401
- 'x-notion-active-user-header': currentCookieData.userId,
402
- 'x-notion-space-id': currentCookieData.spaceId
403
- },
404
- notionApiUrl,
405
- currentCookieData.cookie,
406
- timeoutId
407
- );
408
- }
409
-
410
- if (!response.ok) {
411
- throw new Error(`HTTP error! status: ${response.status}`);
412
- }
413
-
414
- // 处理流式响应
415
- if (!response.body) {
416
- throw new Error("Response body is null");
417
- }
418
-
419
- // 创建流读取器
420
- const reader = response.body;
421
- let buffer = '';
422
-
423
- // 处理数据块
424
- reader.on('data', (chunk) => {
425
- try {
426
- // 标记已收到响应
427
- if (!responseReceived) {
428
- responseReceived = true;
429
- logger.info(`已连接Notion API`);
430
- clearTimeout(timeoutId); // 清除超时计时器
431
- }
432
-
433
- // 解码数据
434
- const text = chunk.toString('utf8');
435
- buffer += text;
436
-
437
- // 按行分割并处理完整的JSON对象
438
- const lines = buffer.split('\n');
439
- buffer = lines.pop() || ''; // 保留最后一行(可能不完整)
440
-
441
- for (const line of lines) {
442
- if (!line.trim()) continue;
443
-
444
- try {
445
- const jsonData = JSON.parse(line);
446
-
447
- // 提取内容
448
- if (jsonData?.type === "markdown-chat" && typeof jsonData?.value === "string") {
449
- const content = jsonData.value;
450
- if (!content) continue;
451
-
452
- // 创建OpenAI格式的块
453
- const chunk = new ChatCompletionChunk({
454
- choices: [
455
- new Choice({
456
- delta: new ChoiceDelta({ content }),
457
- finish_reason: null
458
- })
459
- ]
460
- });
461
-
462
- // 添加到队列
463
- const dataStr = `data: ${JSON.stringify(chunk)}\n\n`;
464
- chunkQueue.write(dataStr);
465
- } else if (jsonData?.recordMap) {
466
- // 忽略recordMap响应
467
- } else {
468
- // 忽略其他类型响应
469
- }
470
- } catch (jsonError) {
471
- logger.error(`解析JSON出错: ${jsonError}`);
472
- }
473
- }
474
- } catch (error) {
475
- logger.error(`处理数据块出错: ${error}`);
476
- }
477
  });
478
-
479
- // 处理流结束
480
- reader.on('end', () => {
481
- try {
482
- logger.info(`响应完成`);
483
- if (cookieManager.getValidCount() > 1){
484
- // 尝试切换到下一个cookie
485
- currentCookieData = cookieManager.getNext();
486
- logger.info(`切换到下一个cookie: ${currentCookieData.userId}`);
487
- }
488
-
489
- // 如果没有收到任何响应,发送一个提示消息
490
- if (!responseReceived) {
491
- logger.warning(`未从Notion收到内容响应,请更换ip重试`);
492
- if (USE_NATIVE_PROXY_POOL) {
493
- proxyPool.removeProxy(proxy.ip, proxy.port);
494
- }
495
-
496
- const noContentChunk = new ChatCompletionChunk({
497
- choices: [
498
- new Choice({
499
- delta: new ChoiceDelta({ content: "未从Notion收到内容响应,请更换ip重试。" }),
500
- finish_reason: "no_content"
501
- })
502
- ]
503
- });
504
- chunkQueue.write(`data: ${JSON.stringify(noContentChunk)}\n\n`);
505
- }
506
-
507
- // 创建结束块
508
- const endChunk = new ChatCompletionChunk({
509
- choices: [
510
- new Choice({
511
- delta: new ChoiceDelta({ content: null }),
512
- finish_reason: "stop"
513
- })
514
- ]
515
- });
516
-
517
- // 添加到队列
518
- chunkQueue.write(`data: ${JSON.stringify(endChunk)}\n\n`);
519
- chunkQueue.write('data: [DONE]\n\n');
520
-
521
- // 清除超时计时器(如果尚未清除)
522
- if (timeoutId) clearTimeout(timeoutId);
523
-
524
- // 清理全局对象
525
- try {
526
- if (global.window) delete global.window;
527
- if (global.document) delete global.document;
528
-
529
- // 安全地删除navigator
530
- if (global.navigator) {
531
- try {
532
- delete global.navigator;
533
- } catch (navError) {
534
- // 如果无法删除,尝试将其设置为undefined
535
- try {
536
- Object.defineProperty(global, 'navigator', {
537
- value: undefined,
538
- writable: true,
539
- configurable: true
540
- });
541
- } catch (defineError) {
542
- logger.warning(`无法清理navigator: ${defineError.message}`);
543
- }
544
- }
545
- }
546
- } catch (cleanupError) {
547
- logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
548
- }
549
-
550
- // 结束流
551
- chunkQueue.end();
552
- } catch (error) {
553
- logger.error(`Error in stream end handler: ${error}`);
554
- if (timeoutId) clearTimeout(timeoutId);
555
-
556
- // 清理全局对象
557
- try {
558
- if (global.window) delete global.window;
559
- if (global.document) delete global.document;
560
-
561
- // 安全地删除navigator
562
- if (global.navigator) {
563
- try {
564
- delete global.navigator;
565
- } catch (navError) {
566
- // 如果无法删除,尝试将其设置为undefined
567
- try {
568
- Object.defineProperty(global, 'navigator', {
569
- value: undefined,
570
- writable: true,
571
- configurable: true
572
- });
573
- } catch (defineError) {
574
- logger.warning(`无法清理navigator: ${defineError.message}`);
575
- }
576
- }
577
- }
578
- } catch (cleanupError) {
579
- logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
580
- }
581
-
582
- chunkQueue.end();
583
  }
 
584
  });
585
-
586
- // 处理错误
587
- reader.on('error', (error) => {
588
- logger.error(`Stream error: ${error}`);
589
  if (timeoutId) clearTimeout(timeoutId);
590
-
591
- // 清理全局对象
592
- try {
593
- if (global.window) delete global.window;
594
- if (global.document) delete global.document;
595
-
596
- // 安全地删除navigator
597
- if (global.navigator) {
598
- try {
599
- delete global.navigator;
600
- } catch (navError) {
601
- // 如果无法删除,尝试将其设置为undefined
602
- try {
603
- Object.defineProperty(global, 'navigator', {
604
- value: undefined,
605
- writable: true,
606
- configurable: true
607
- });
608
- } catch (defineError) {
609
- logger.warning(`无法清理navigator: ${defineError.message}`);
610
- }
611
- }
612
- }
613
- } catch (cleanupError) {
614
- logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
615
- }
616
-
617
- try {
618
- const errorChunk = new ChatCompletionChunk({
619
- choices: [
620
- new Choice({
621
- delta: new ChoiceDelta({ content: `流读取错误: ${error.message}` }),
622
- finish_reason: "error"
623
- })
624
- ]
625
- });
626
- chunkQueue.write(`data: ${JSON.stringify(errorChunk)}\n\n`);
627
- chunkQueue.write('data: [DONE]\n\n');
628
- } catch (e) {
629
- logger.error(`Error sending error message: ${e}`);
630
- } finally {
631
- chunkQueue.end();
632
- }
633
  });
634
  } catch (error) {
635
- logger.error(`Notion API请��失败: ${error}`);
636
- // 清理全局对象
637
- try {
638
- if (global.window) delete global.window;
639
- if (global.document) delete global.document;
640
-
641
- // 安全地删除navigator
642
- if (global.navigator) {
643
- try {
644
- delete global.navigator;
645
- } catch (navError) {
646
- // 如果无法删除,尝试将其设置为undefined
647
- try {
648
- Object.defineProperty(global, 'navigator', {
649
- value: undefined,
650
- writable: true,
651
- configurable: true
652
- });
653
- } catch (defineError) {
654
- logger.warning(`无法清理navigator: ${defineError.message}`);
655
- }
656
- }
657
- }
658
- } catch (cleanupError) {
659
- logger.warning(`清理全局对象时出错: ${cleanupError.message}`);
660
- }
661
-
662
- if (timeoutId) clearTimeout(timeoutId);
663
- if (chunkQueue) chunkQueue.end();
664
-
665
- // 确保在错误情况下也触发流结束
666
- try {
667
- if (!responseReceived && chunkQueue) {
668
- const errorChunk = new ChatCompletionChunk({
669
- choices: [
670
- new Choice({
671
- delta: new ChoiceDelta({ content: `Notion API请求失败: ${error.message}` }),
672
- finish_reason: "error"
673
- })
674
- ]
675
- });
676
- chunkQueue.write(`data: ${JSON.stringify(errorChunk)}\n\n`);
677
- chunkQueue.write('data: [DONE]\n\n');
678
- }
679
- } catch (e) {
680
- logger.error(`发送错误消息时出错: ${e}`);
681
- }
682
-
683
- throw error; // 重新抛出错误以便上层捕获
684
  }
685
  }
686
 
@@ -688,12 +311,12 @@ async function fetchNotionResponse(chunkQueue, notionRequestBody, headers, notio
688
  async function initialize() {
689
  logger.info(`初始化Notion配置...`);
690
 
691
- // 启动代理服务器
692
- try {
693
- await proxyServer.start();
694
- } catch (error) {
695
- logger.error(`启动代理服务器失败: ${error.message}`);
696
- }
697
 
698
  // 初始化cookie管理器
699
  let initResult = false;
@@ -741,10 +364,10 @@ async function initialize() {
741
  logger.info(`当前使用的cookie对应的用户ID: ${currentCookieData.userId}`);
742
  logger.info(`当前使用的cookie对应的空间ID: ${currentCookieData.spaceId}`);
743
 
744
- if (process.env.USE_NATIVE_PROXY_POOL === 'true') {
745
- logger.info(`正在初始化本地代理池...`);
746
- await proxyPool.initialize();
747
- }
748
 
749
  INITIALIZED_SUCCESSFULLY = true;
750
  }
 
14
  import { proxyPool } from './ProxyPool.js';
15
  import { proxyServer } from './ProxyServer.js';
16
  import { cookieManager } from './CookieManager.js';
17
+ import { gotScraping } from 'got-scraping';
18
 
19
  // 获取当前文件的目录路径
20
  const __filename = fileURLToPath(import.meta.url);
 
228
  const timeoutId = setTimeout(() => {
229
  logger.warning(`请求超时,30秒内未收到响应`);
230
  try {
231
+ if (!responseReceived) {
232
+ stream.end();
233
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  } catch (e) {
235
+ logger.error(`关闭超时流时出错: ${e.message}`);
 
 
236
  }
237
+ }, 30000);
 
 
 
238
 
 
 
239
  let responseReceived = false;
 
240
 
241
  try {
242
+ const notionApiUrl = getNotionApiUrl(currentCookieData.userId);
243
+ const notionCookie = cookieManager.getCookieString(currentCookieData.userId);
244
+
245
+ // 配置 got-scraping
246
+ const options = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  method: 'POST',
248
+ headers: headers,
 
 
 
 
249
  body: JSON.stringify(notionRequestBody),
250
+ isStream: true,
251
+ cookieJar: await cookieManager.getGotCookieJar(notionCookie),
252
+ timeout: { request: 30000 },
253
+ http2: true, // 使用HTTP/2,这对于模拟浏览器很重要
254
+ headerGeneratorOptions: { // 伪造浏览器头
255
+ browsers: ['chrome'],
256
+ devices: ['desktop'],
257
+ locales: ['en-US'],
258
+ operatingSystems: ['windows'],
259
+ },
260
  };
261
+
262
+ // 如果配置了代理,则使用它
263
+ if (PROXY_URL) {
264
+ options.proxyUrl = PROXY_URL;
 
 
 
 
 
 
 
 
 
 
 
 
265
  logger.info(`使用代理: ${PROXY_URL}`);
266
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
+ const responseStream = gotScraping(notionApiUrl, options);
269
+
270
+ // 监听流事件
271
+ fetchNotionResponse(stream, responseStream, timeoutId);
272
+ } catch (error) {
273
+ logger.error(`创建 got-scraping 请求时出错: ${error.message}`);
274
+ if (timeoutId) clearTimeout(timeoutId);
275
+ stream.end();
276
+ }
277
+
278
+ return stream;
279
+ }
280
+
281
+ // 使用got-scraping的流处理函数
282
+ async function fetchNotionResponse(chunkQueue, responseStream, timeoutId) {
283
+ let responseReceived = false;
284
+ try {
285
+ responseStream.on('data', (chunk) => {
286
+ responseReceived = true;
287
+ chunkQueue.write(chunk);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  });
289
+
290
+ responseStream.on('end', () => {
291
+ if (timeoutId) clearTimeout(timeoutId);
292
+ if (!responseReceived) {
293
+ logger.warning('流已结束但未收到任何数据');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  }
295
+ chunkQueue.end();
296
  });
297
+
298
+ responseStream.on('error', (error) => {
299
+ logger.error(`got-scraping 响应流错误: ${error.message}`);
 
300
  if (timeoutId) clearTimeout(timeoutId);
301
+ chunkQueue.end();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  });
303
  } catch (error) {
304
+ logger.error(`处理 got-scraping 响应时出错: ${error.message}`);
305
+ if (timeoutId) clearTimeout(timeoutId);
306
+ chunkQueue.end();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  }
308
  }
309
 
 
311
  async function initialize() {
312
  logger.info(`初始化Notion配置...`);
313
 
314
+ // 启动代理服务器 - 已禁用
315
+ // try {
316
+ // await proxyServer.start();
317
+ // } catch (error) {
318
+ // logger.error(`启动代理服务器失败: ${error.message}`);
319
+ // }
320
 
321
  // 初始化cookie管理器
322
  let initResult = false;
 
364
  logger.info(`当前使用的cookie对应的用户ID: ${currentCookieData.userId}`);
365
  logger.info(`当前使用的cookie对应的空间ID: ${currentCookieData.spaceId}`);
366
 
367
+ // if (process.env.USE_NATIVE_PROXY_POOL === 'true') {
368
+ // logger.info(`正在初始化本地代理池...`);
369
+ // await proxyPool.initialize();
370
+ // }
371
 
372
  INITIALIZED_SUCCESSFULLY = true;
373
  }