Spaces:
Sleeping
Sleeping
Revert "feat: Implement and integrate a `wreq-js` based TLS client for all network requests."
Browse files- package-lock.json +3 -22
- package.json +1 -2
- src/index.js +1 -9
- src/utils/helpers.js +1 -2
- src/utils/tls-client.js +0 -102
package-lock.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 1 |
{
|
| 2 |
"name": "antigravity-claude-proxy",
|
| 3 |
-
"version": "2.
|
| 4 |
"lockfileVersion": 3,
|
| 5 |
"requires": true,
|
| 6 |
"packages": {
|
| 7 |
"": {
|
| 8 |
"name": "antigravity-claude-proxy",
|
| 9 |
-
"version": "2.
|
| 10 |
"license": "MIT",
|
| 11 |
"dependencies": {
|
| 12 |
"async-mutex": "^0.5.0",
|
| 13 |
"better-sqlite3": "^12.5.0",
|
| 14 |
"cors": "^2.8.5",
|
| 15 |
"express": "^4.18.2",
|
| 16 |
-
"undici": "^7.20.0"
|
| 17 |
-
"wreq-js": "^2.0.1"
|
| 18 |
},
|
| 19 |
"bin": {
|
| 20 |
"antigravity-claude-proxy": "bin/cli.js"
|
|
@@ -2823,24 +2822,6 @@
|
|
| 2823 |
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
| 2824 |
"license": "ISC"
|
| 2825 |
},
|
| 2826 |
-
"node_modules/wreq-js": {
|
| 2827 |
-
"version": "2.0.1",
|
| 2828 |
-
"resolved": "https://registry.npmjs.org/wreq-js/-/wreq-js-2.0.1.tgz",
|
| 2829 |
-
"integrity": "sha512-7GcZpzVtRX/A5pqu2QXTcqKTiYJZZRIRiosJ94GT1+taQivysZmjvkwzk8IvLz1oE1P1rGWG8ujDLCYxusM1aQ==",
|
| 2830 |
-
"cpu": [
|
| 2831 |
-
"x64",
|
| 2832 |
-
"arm64"
|
| 2833 |
-
],
|
| 2834 |
-
"license": "MIT",
|
| 2835 |
-
"os": [
|
| 2836 |
-
"darwin",
|
| 2837 |
-
"linux",
|
| 2838 |
-
"win32"
|
| 2839 |
-
],
|
| 2840 |
-
"engines": {
|
| 2841 |
-
"node": ">=20.0.0"
|
| 2842 |
-
}
|
| 2843 |
-
},
|
| 2844 |
"node_modules/y18n": {
|
| 2845 |
"version": "5.0.8",
|
| 2846 |
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "antigravity-claude-proxy",
|
| 3 |
+
"version": "2.5.0",
|
| 4 |
"lockfileVersion": 3,
|
| 5 |
"requires": true,
|
| 6 |
"packages": {
|
| 7 |
"": {
|
| 8 |
"name": "antigravity-claude-proxy",
|
| 9 |
+
"version": "2.5.0",
|
| 10 |
"license": "MIT",
|
| 11 |
"dependencies": {
|
| 12 |
"async-mutex": "^0.5.0",
|
| 13 |
"better-sqlite3": "^12.5.0",
|
| 14 |
"cors": "^2.8.5",
|
| 15 |
"express": "^4.18.2",
|
| 16 |
+
"undici": "^7.20.0"
|
|
|
|
| 17 |
},
|
| 18 |
"bin": {
|
| 19 |
"antigravity-claude-proxy": "bin/cli.js"
|
|
|
|
| 2822 |
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
| 2823 |
"license": "ISC"
|
| 2824 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2825 |
"node_modules/y18n": {
|
| 2826 |
"version": "5.0.8",
|
| 2827 |
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
package.json
CHANGED
|
@@ -63,8 +63,7 @@
|
|
| 63 |
"better-sqlite3": "^12.5.0",
|
| 64 |
"cors": "^2.8.5",
|
| 65 |
"express": "^4.18.2",
|
| 66 |
-
"undici": "^7.20.0"
|
| 67 |
-
"wreq-js": "^2.0.1"
|
| 68 |
},
|
| 69 |
"devDependencies": {
|
| 70 |
"@tailwindcss/forms": "^0.5.7",
|
|
|
|
| 63 |
"better-sqlite3": "^12.5.0",
|
| 64 |
"cors": "^2.8.5",
|
| 65 |
"express": "^4.18.2",
|
| 66 |
+
"undici": "^7.20.0"
|
|
|
|
| 67 |
},
|
| 68 |
"devDependencies": {
|
| 69 |
"@tailwindcss/forms": "^0.5.7",
|
src/index.js
CHANGED
|
@@ -12,7 +12,6 @@ import { logger } from './utils/logger.js';
|
|
| 12 |
import { config } from './config.js';
|
| 13 |
import { getStrategyLabel, STRATEGY_NAMES, DEFAULT_STRATEGY } from './account-manager/strategies/index.js';
|
| 14 |
import { getPackageVersion } from './utils/helpers.js';
|
| 15 |
-
import tlsClient from './utils/tls-client.js';
|
| 16 |
import path from 'path';
|
| 17 |
import os from 'os';
|
| 18 |
|
|
@@ -160,15 +159,8 @@ ${environmentSection}
|
|
| 160 |
});
|
| 161 |
|
| 162 |
// Graceful shutdown
|
| 163 |
-
const shutdown =
|
| 164 |
logger.info('Shutting down server...');
|
| 165 |
-
|
| 166 |
-
try {
|
| 167 |
-
await tlsClient.exit();
|
| 168 |
-
} catch (err) {
|
| 169 |
-
logger.error('Error shutting down TLS client:', err);
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
server.close(() => {
|
| 173 |
logger.success('Server stopped');
|
| 174 |
process.exit(0);
|
|
|
|
| 12 |
import { config } from './config.js';
|
| 13 |
import { getStrategyLabel, STRATEGY_NAMES, DEFAULT_STRATEGY } from './account-manager/strategies/index.js';
|
| 14 |
import { getPackageVersion } from './utils/helpers.js';
|
|
|
|
| 15 |
import path from 'path';
|
| 16 |
import os from 'os';
|
| 17 |
|
|
|
|
| 159 |
});
|
| 160 |
|
| 161 |
// Graceful shutdown
|
| 162 |
+
const shutdown = () => {
|
| 163 |
logger.info('Shutting down server...');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
server.close(() => {
|
| 165 |
logger.success('Server stopped');
|
| 166 |
process.exit(0);
|
src/utils/helpers.js
CHANGED
|
@@ -2,7 +2,6 @@ import { readFileSync } from 'fs';
|
|
| 2 |
import { fileURLToPath } from 'url';
|
| 3 |
import path from 'path';
|
| 4 |
import { config } from '../config.js';
|
| 5 |
-
import tlsClient from './tls-client.js';
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Shared Utility Functions
|
|
@@ -87,7 +86,7 @@ export async function throttledFetch(url, options) {
|
|
| 87 |
await sleep(delayMs);
|
| 88 |
}
|
| 89 |
}
|
| 90 |
-
return
|
| 91 |
}
|
| 92 |
|
| 93 |
/**
|
|
|
|
| 2 |
import { fileURLToPath } from 'url';
|
| 3 |
import path from 'path';
|
| 4 |
import { config } from '../config.js';
|
|
|
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Shared Utility Functions
|
|
|
|
| 86 |
await sleep(delayMs);
|
| 87 |
}
|
| 88 |
}
|
| 89 |
+
return fetch(url, options);
|
| 90 |
}
|
| 91 |
|
| 92 |
/**
|
src/utils/tls-client.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
| 1 |
-
import { createRequire } from 'module';
|
| 2 |
-
import { Readable } from 'stream';
|
| 3 |
-
import { getPlatformUserAgent } from '../constants.js';
|
| 4 |
-
|
| 5 |
-
const require = createRequire(import.meta.url);
|
| 6 |
-
const { createSession } = require('wreq-js');
|
| 7 |
-
|
| 8 |
-
class TlsClient {
|
| 9 |
-
constructor() {
|
| 10 |
-
this.userAgent = getPlatformUserAgent();
|
| 11 |
-
this.session = null;
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
async getSession() {
|
| 15 |
-
if (this.session) return this.session;
|
| 16 |
-
this.session = await createSession({
|
| 17 |
-
browser: 'chrome_124',
|
| 18 |
-
os: 'macos',
|
| 19 |
-
userAgent: this.userAgent
|
| 20 |
-
});
|
| 21 |
-
return this.session;
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
async fetch(url, options = {}) {
|
| 25 |
-
const session = await this.getSession();
|
| 26 |
-
const method = (options.method || 'GET').toUpperCase();
|
| 27 |
-
|
| 28 |
-
const wreqOptions = {
|
| 29 |
-
method,
|
| 30 |
-
headers: options.headers,
|
| 31 |
-
body: options.body,
|
| 32 |
-
redirect: options.redirect === 'manual' ? 'manual' : 'follow',
|
| 33 |
-
};
|
| 34 |
-
|
| 35 |
-
try {
|
| 36 |
-
const response = await session.fetch(url, wreqOptions);
|
| 37 |
-
return new ResponseWrapper(response);
|
| 38 |
-
} catch (error) {
|
| 39 |
-
console.error('wreq-js fetch failed:', error);
|
| 40 |
-
throw error;
|
| 41 |
-
}
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
async exit() {
|
| 45 |
-
if (this.session) {
|
| 46 |
-
await this.session.close();
|
| 47 |
-
this.session = null;
|
| 48 |
-
}
|
| 49 |
-
}
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
class ResponseWrapper {
|
| 53 |
-
constructor(wreqResponse) {
|
| 54 |
-
this.status = wreqResponse.status;
|
| 55 |
-
this.statusText = wreqResponse.statusText || (this.status === 200 ? 'OK' : `Status ${this.status}`);
|
| 56 |
-
this.headers = new Headers(wreqResponse.headers);
|
| 57 |
-
this.url = wreqResponse.url;
|
| 58 |
-
this.ok = this.status >= 200 && this.status < 300;
|
| 59 |
-
|
| 60 |
-
if (wreqResponse.body) {
|
| 61 |
-
if (typeof wreqResponse.body.getReader === 'function') {
|
| 62 |
-
this.body = wreqResponse.body;
|
| 63 |
-
} else {
|
| 64 |
-
this.body = Readable.toWeb(wreqResponse.body);
|
| 65 |
-
}
|
| 66 |
-
} else {
|
| 67 |
-
this.body = null;
|
| 68 |
-
}
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
async text() {
|
| 72 |
-
if (!this.body) return '';
|
| 73 |
-
const reader = this.body.getReader();
|
| 74 |
-
const chunks = [];
|
| 75 |
-
while (true) {
|
| 76 |
-
const { done, value } = await reader.read();
|
| 77 |
-
if (done) break;
|
| 78 |
-
chunks.push(typeof value === 'string' ? Buffer.from(value) : value);
|
| 79 |
-
}
|
| 80 |
-
return Buffer.concat(chunks).toString('utf8');
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
async json() {
|
| 84 |
-
const text = await this.text();
|
| 85 |
-
return JSON.parse(text);
|
| 86 |
-
}
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
class Headers {
|
| 90 |
-
constructor(headersObj = {}) {
|
| 91 |
-
this.map = new Map();
|
| 92 |
-
for (const [key, value] of Object.entries(headersObj)) {
|
| 93 |
-
this.map.set(key.toLowerCase(), Array.isArray(value) ? value.join(', ') : value);
|
| 94 |
-
}
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
get(name) { return this.map.get(name.toLowerCase()) || null; }
|
| 98 |
-
has(name) { return this.map.has(name.toLowerCase()); }
|
| 99 |
-
forEach(callback) { this.map.forEach(callback); }
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
export default new TlsClient();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|