@zebpay_rajesh/zebpay-mcp-server 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +14 -0
- package/README.md +223 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +81 -0
- package/dist/config.js.map +1 -0
- package/dist/http/httpClient.d.ts +40 -0
- package/dist/http/httpClient.js +341 -0
- package/dist/http/httpClient.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/errors.d.ts +21 -0
- package/dist/mcp/errors.js +214 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/logging.d.ts +21 -0
- package/dist/mcp/logging.js +241 -0
- package/dist/mcp/logging.js.map +1 -0
- package/dist/mcp/prompts.d.ts +9 -0
- package/dist/mcp/prompts.js +165 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +9 -0
- package/dist/mcp/resources.js +125 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/tools_futures.d.ts +5 -0
- package/dist/mcp/tools_futures.js +694 -0
- package/dist/mcp/tools_futures.js.map +1 -0
- package/dist/mcp/tools_spot.d.ts +11 -0
- package/dist/mcp/tools_spot.js +2225 -0
- package/dist/mcp/tools_spot.js.map +1 -0
- package/dist/private/FuturesClient.d.ts +57 -0
- package/dist/private/FuturesClient.js +181 -0
- package/dist/private/FuturesClient.js.map +1 -0
- package/dist/private/SpotClient.d.ts +44 -0
- package/dist/private/SpotClient.js +201 -0
- package/dist/private/SpotClient.js.map +1 -0
- package/dist/private/ZebpayAPI.d.ts +19 -0
- package/dist/private/ZebpayAPI.js +172 -0
- package/dist/private/ZebpayAPI.js.map +1 -0
- package/dist/public/PublicClient.d.ts +79 -0
- package/dist/public/PublicClient.js +283 -0
- package/dist/public/PublicClient.js.map +1 -0
- package/dist/public/PublicFuturesClient.d.ts +27 -0
- package/dist/public/PublicFuturesClient.js +187 -0
- package/dist/public/PublicFuturesClient.js.map +1 -0
- package/dist/security/credentials.d.ts +42 -0
- package/dist/security/credentials.js +80 -0
- package/dist/security/credentials.js.map +1 -0
- package/dist/security/signing.d.ts +33 -0
- package/dist/security/signing.js +56 -0
- package/dist/security/signing.js.map +1 -0
- package/dist/types/responses.d.ts +130 -0
- package/dist/types/responses.js +6 -0
- package/dist/types/responses.js.map +1 -0
- package/dist/utils/cache.d.ts +29 -0
- package/dist/utils/cache.js +72 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/fileLogger.d.ts +10 -0
- package/dist/utils/fileLogger.js +81 -0
- package/dist/utils/fileLogger.js.map +1 -0
- package/dist/utils/metrics.d.ts +35 -0
- package/dist/utils/metrics.js +94 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/responseFormatter.d.ts +93 -0
- package/dist/utils/responseFormatter.js +268 -0
- package/dist/utils/responseFormatter.js.map +1 -0
- package/dist/validation/schemas.d.ts +70 -0
- package/dist/validation/schemas.js +48 -0
- package/dist/validation/schemas.js.map +1 -0
- package/dist/validation/validators.d.ts +28 -0
- package/dist/validation/validators.js +129 -0
- package/dist/validation/validators.js.map +1 -0
- package/package.json +54 -0
package/.env.example
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
ZEBPAY_API_KEY=
|
|
2
|
+
ZEBPAY_API_SECRET=
|
|
3
|
+
|
|
4
|
+
# Required runtime configuration (no fallback defaults in code)
|
|
5
|
+
ZEBPAY_SPOT_BASE_URL=https://www.zebapi.com/api/v2
|
|
6
|
+
ZEBPAY_FUTURES_BASE_URL=https://futures-api.zebpay.com/api/v1
|
|
7
|
+
ZEBPAY_MARKET_BASE_URL=https://www.zebapi.com/api/v1/market
|
|
8
|
+
|
|
9
|
+
MCP_TRANSPORTS=stdio
|
|
10
|
+
LOG_LEVEL=info
|
|
11
|
+
HTTP_TIMEOUT_MS=15000
|
|
12
|
+
HTTP_RETRY_COUNT=2
|
|
13
|
+
|
|
14
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Zebpay MCP Server
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Production-ready TypeScript **MCP (Model Context Protocol)** server for Zebpay spot and futures APIs, using **stdio transport only**.
|
|
6
|
+
Model Context Protocol (MCP) is a standard way for AI assistants to securely call tools and data sources.
|
|
7
|
+
It is designed for MCP clients like Cursor, Claude Desktop, and MCP Inspector that connect through local process execution.
|
|
8
|
+
The server provides both market-data and trading workflows with strict validation, safe error handling, and developer-friendly observability.
|
|
9
|
+
|
|
10
|
+
## What This Server Provides
|
|
11
|
+
|
|
12
|
+
- Public market data tools (spot + futures)
|
|
13
|
+
- Private trading/account tools (requires API credentials)
|
|
14
|
+
- MCP resources and prompts for agent workflows
|
|
15
|
+
- Request validation via Zod
|
|
16
|
+
- Structured error handling and optional file logging
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Stdio-only MCP server for secure local integration with MCP clients
|
|
21
|
+
- Spot and futures API coverage for both public and authenticated operations
|
|
22
|
+
- HMAC-based authenticated request flow for private endpoints
|
|
23
|
+
- Input validation and normalized MCP error responses
|
|
24
|
+
- Outbound request retries and timeout controls
|
|
25
|
+
- Optional structured file logging for debugging and auditability
|
|
26
|
+
|
|
27
|
+
## Supported Tools
|
|
28
|
+
|
|
29
|
+
### Spot (Public + Private)
|
|
30
|
+
|
|
31
|
+
- Market data: tickers, order book, trades, klines, exchange info, currencies
|
|
32
|
+
- Trading: place market/limit orders, cancel orders, cancel by symbol, cancel all
|
|
33
|
+
- Account: balances, open orders, order history, trade history, exchange fee
|
|
34
|
+
- Example tool names:
|
|
35
|
+
- `zebpay_public_getTicker`
|
|
36
|
+
- `zebpay_public_getOrderBook`
|
|
37
|
+
- `zebpay_spot_placeMarketOrder`
|
|
38
|
+
- `zebpay_spot_placeLimitOrder`
|
|
39
|
+
- `zebpay_spot_getBalance`
|
|
40
|
+
|
|
41
|
+
### Futures (Public + Private)
|
|
42
|
+
|
|
43
|
+
- Market data: health status, markets, market info, order book, 24h ticker, aggregate trades
|
|
44
|
+
- Trading/account: wallet balance, place order, add/reduce margin, open orders, positions
|
|
45
|
+
- History: order history, linked orders, trade history, transaction history
|
|
46
|
+
- Example tool names:
|
|
47
|
+
- `zebpay_futures_public_getMarkets`
|
|
48
|
+
- `zebpay_futures_public_getOrderBook`
|
|
49
|
+
- `zebpay_futures_placeOrder`
|
|
50
|
+
- `zebpay_futures_getWalletBalance`
|
|
51
|
+
- `zebpay_futures_getPositions`
|
|
52
|
+
|
|
53
|
+
## Tech Stack
|
|
54
|
+
|
|
55
|
+
- Node.js (ESM)
|
|
56
|
+
- TypeScript
|
|
57
|
+
- `@modelcontextprotocol/sdk`
|
|
58
|
+
- `undici`
|
|
59
|
+
- `zod`
|
|
60
|
+
|
|
61
|
+
## Project Structure
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
src/
|
|
65
|
+
├── index.ts # Stdio MCP server entrypoint
|
|
66
|
+
├── mcp/ # Tools, resources, prompts, MCP errors/logging
|
|
67
|
+
├── private/ # Authenticated Zebpay clients
|
|
68
|
+
├── public/ # Public market-data clients
|
|
69
|
+
├── security/ # Credentials + signing helpers
|
|
70
|
+
├── http/ # Shared outbound HTTP client to Zebpay APIs
|
|
71
|
+
├── validation/ # Schemas and validation helpers
|
|
72
|
+
├── utils/ # Caching, metrics, formatting, file logging
|
|
73
|
+
└── types/ # Shared response types
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Prerequisites
|
|
77
|
+
|
|
78
|
+
- Node.js 20+
|
|
79
|
+
- npm 9+
|
|
80
|
+
- Zebpay API credentials (for private tools)
|
|
81
|
+
- Create your API key/secret from the official ZebPay API portal: `https://api.zebpay.com/`
|
|
82
|
+
|
|
83
|
+
## Creating a ZebPay API Key
|
|
84
|
+
|
|
85
|
+
Use the steps below to generate API credentials for this MCP server:
|
|
86
|
+
|
|
87
|
+
1. Open the ZebPay API portal: `https://api.zebpay.com/`
|
|
88
|
+
2. Sign in to your ZebPay account.
|
|
89
|
+
3. Go to **API Trading** and click **Create New API Key**.
|
|
90
|
+
4. Enter key details:
|
|
91
|
+
- key name (for example: `zebpay-mcp-local`)
|
|
92
|
+
- required permissions (read-only for market/account checks, trading permissions only if needed)
|
|
93
|
+
- optional IP whitelist (recommended for better security)
|
|
94
|
+
5. Complete OTP verification.
|
|
95
|
+
6. Copy and save:
|
|
96
|
+
- API Key
|
|
97
|
+
- Secret Key (shown once)
|
|
98
|
+
|
|
99
|
+
Then add them to your local `.env` file:
|
|
100
|
+
|
|
101
|
+
```env
|
|
102
|
+
ZEBPAY_API_KEY=your_api_key
|
|
103
|
+
ZEBPAY_API_SECRET=your_api_secret
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Security notes:
|
|
107
|
+
|
|
108
|
+
- Never commit API keys/secrets to git.
|
|
109
|
+
- Prefer least-privilege API permissions.
|
|
110
|
+
- Rotate keys immediately if exposed.
|
|
111
|
+
|
|
112
|
+
## Setup
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
git clone <your-repo-url>
|
|
116
|
+
cd zebpay-mcp-server
|
|
117
|
+
npm install
|
|
118
|
+
cp env.example .env
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Update `.env` (all values are read from environment; there are no fallback defaults in code):
|
|
122
|
+
|
|
123
|
+
```env
|
|
124
|
+
ZEBPAY_API_KEY=your_api_key # Use the API key from the step above
|
|
125
|
+
ZEBPAY_API_SECRET=your_api_secret # Use the Secret key from the step above
|
|
126
|
+
ZEBPAY_SPOT_BASE_URL=https://sapi.zebpay.com/api/v2
|
|
127
|
+
ZEBPAY_FUTURES_BASE_URL=https://futuresbe.zebpay.com/api/v1
|
|
128
|
+
ZEBPAY_MARKET_BASE_URL=https://www.zebapi.com/api/v1/market
|
|
129
|
+
MCP_TRANSPORTS=stdio
|
|
130
|
+
LOG_LEVEL=info
|
|
131
|
+
HTTP_TIMEOUT_MS=15000
|
|
132
|
+
HTTP_RETRY_COUNT=2
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Build and Run
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npm run build
|
|
139
|
+
npm start
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Optional logging to file:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm run start:log
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## MCP Client Configuration (Stdio)
|
|
149
|
+
|
|
150
|
+
Example MCP client config:
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"mcpServers": {
|
|
155
|
+
"zebpay": {
|
|
156
|
+
"command": "node",
|
|
157
|
+
"args": [
|
|
158
|
+
"/absolute/path/to/zebpay-mcp-server/dist/index.js"
|
|
159
|
+
],
|
|
160
|
+
"env": {
|
|
161
|
+
"ZEBPAY_API_KEY": "YOUR_API_KEY_HERE",
|
|
162
|
+
"ZEBPAY_API_SECRET": "YOUR_API_SECRET_HERE",
|
|
163
|
+
"LOG_LEVEL": "info"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
[<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=zebpay&config=eyJjb21tYW5kIjoibm9kZSIsImFyZ3MiOlsiL2Fic29sdXRlL3BhdGgvdG8vemVicGF5LW1jcC1zZXJ2ZXIvZGlzdC9pbmRleC5qcyJdLCJlbnYiOnsiWkVCUEFZX0FQSV9LRVkiOiJZT1VSX0FQSV9LRVlfSEVSRSIsIlpFQlBBWV9BUElfU0VDUkVUIjoiWU9VUl9BUElfU0VDUkVUX0hFUkUiLCJMT0dfTEVWRUwiOiJpbmZvIn19)
|
|
170
|
+
|
|
171
|
+
Also see: `mcp-config.json.example`.
|
|
172
|
+
|
|
173
|
+
## Environment Variables
|
|
174
|
+
|
|
175
|
+
| Variable | Required | Description | Example value |
|
|
176
|
+
| ------------------------- | -------- | ---------------------------------------------- | --------------------------------------- |
|
|
177
|
+
| `ZEBPAY_API_KEY` | Yes | Zebpay API key (required for private tools) | `YOUR_API_KEY_HERE` |
|
|
178
|
+
| `ZEBPAY_API_SECRET` | Yes | Zebpay API secret (required for private tools) | `YOUR_API_SECRET_HERE` |
|
|
179
|
+
| `MCP_TRANSPORTS` | Yes | Must be `stdio` | `stdio` |
|
|
180
|
+
| `ZEBPAY_SPOT_BASE_URL` | Yes | Spot API base URL | `https://www.zebapi.com/api/v2` |
|
|
181
|
+
| `ZEBPAY_FUTURES_BASE_URL` | Yes | Futures API base URL | `https://futures-api.zebpay.com/api/v1` |
|
|
182
|
+
| `ZEBPAY_MARKET_BASE_URL` | Yes | Market API base URL | `https://www.zebapi.com/api/v1/market` |
|
|
183
|
+
| `LOG_LEVEL` | Yes | `debug`, `info`, `warn`, `error` | `info` |
|
|
184
|
+
| `LOG_FILE` | No | File path for logs | `logs/mcp-server.log` |
|
|
185
|
+
| `HTTP_TIMEOUT_MS` | Yes | Outbound request timeout (ms) | `15000` |
|
|
186
|
+
| `HTTP_RETRY_COUNT` | Yes | Retry count for outbound requests | `2` |
|
|
187
|
+
|
|
188
|
+
## Developer Commands
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm run build
|
|
192
|
+
npm test
|
|
193
|
+
npm run test:watch
|
|
194
|
+
npm run logs
|
|
195
|
+
npm run logs:watch
|
|
196
|
+
npm run logs:errors
|
|
197
|
+
npm run logs:stats
|
|
198
|
+
npm run logs:clear
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Logging
|
|
202
|
+
|
|
203
|
+
- Log tools and examples: `scripts/README.md`
|
|
204
|
+
- Full logging docs: `docs/LOGGING.md`
|
|
205
|
+
- Keep logs out of git (`logs/` is ignored)
|
|
206
|
+
|
|
207
|
+
## Issues
|
|
208
|
+
|
|
209
|
+
Found a bug or want to request a feature?
|
|
210
|
+
|
|
211
|
+
- Create an issue from the GitHub **Issues** tab for this repository.
|
|
212
|
+
- You can also use direct links after replacing `<your-org>` and `<your-repo>`:
|
|
213
|
+
- Bug report: `https://github.com/<your-org>/<your-repo>/issues/new?template=bug_report.md`
|
|
214
|
+
- Feature request: `https://github.com/<your-org>/<your-repo>/issues/new?template=feature_request.md`
|
|
215
|
+
- Include these details for faster triage:
|
|
216
|
+
- MCP client used (Cursor/Claude Desktop/other)
|
|
217
|
+
- Node.js version and OS
|
|
218
|
+
- Minimal reproduction steps
|
|
219
|
+
- Relevant logs (redact secrets)
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
MIT
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type TransportKind = "stdio";
|
|
2
|
+
export interface SigningHeaderNames {
|
|
3
|
+
apiKeyHeader: string;
|
|
4
|
+
signatureHeader: string;
|
|
5
|
+
timestampHeader: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AppConfig {
|
|
8
|
+
spotBaseUrl: string;
|
|
9
|
+
futuresBaseUrl: string;
|
|
10
|
+
marketBaseUrl: string;
|
|
11
|
+
transports: TransportKind[];
|
|
12
|
+
logLevel: "debug" | "info" | "warn" | "error";
|
|
13
|
+
logFile?: string;
|
|
14
|
+
signingHeaders: SigningHeaderNames;
|
|
15
|
+
timeoutMs: number;
|
|
16
|
+
retryCount: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function redact(value: string | undefined | null, show?: number): string;
|
|
19
|
+
export declare function getConfig(): AppConfig;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Centralized configuration loading and validation.
|
|
3
|
+
Secrets are never logged; use redact() when including values in logs.
|
|
4
|
+
*/
|
|
5
|
+
const SIGNING_HEADERS = {
|
|
6
|
+
apiKeyHeader: "X-AUTH-APIKEY",
|
|
7
|
+
signatureHeader: "X-AUTH-SIGNATURE",
|
|
8
|
+
timestampHeader: "",
|
|
9
|
+
};
|
|
10
|
+
export function redact(value, show = 4) {
|
|
11
|
+
if (!value)
|
|
12
|
+
return "<redacted>";
|
|
13
|
+
if (value.length <= show)
|
|
14
|
+
return "*".repeat(value.length);
|
|
15
|
+
return `${value.slice(0, show)}${"*".repeat(Math.max(4, value.length - show))}`;
|
|
16
|
+
}
|
|
17
|
+
function getRequiredEnv(name) {
|
|
18
|
+
const value = process.env[name];
|
|
19
|
+
if (value === undefined) {
|
|
20
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function parseTransports(input) {
|
|
25
|
+
const raw = (input ?? "stdio").split(",").map((s) => s.trim()).filter(Boolean);
|
|
26
|
+
const valid = [];
|
|
27
|
+
for (const t of raw) {
|
|
28
|
+
if (t === "stdio")
|
|
29
|
+
valid.push(t);
|
|
30
|
+
}
|
|
31
|
+
if (!valid.length) {
|
|
32
|
+
throw new Error('Invalid MCP_TRANSPORTS. Only "stdio" is supported.');
|
|
33
|
+
}
|
|
34
|
+
return valid;
|
|
35
|
+
}
|
|
36
|
+
function parseLogLevel(input) {
|
|
37
|
+
if (input === undefined)
|
|
38
|
+
return "info";
|
|
39
|
+
if (input === "debug" || input === "info" || input === "warn" || input === "error") {
|
|
40
|
+
return input;
|
|
41
|
+
}
|
|
42
|
+
throw new Error('Invalid LOG_LEVEL. Use one of: "debug", "info", "warn", "error".');
|
|
43
|
+
}
|
|
44
|
+
export function getConfig() {
|
|
45
|
+
const spotBaseUrl = getRequiredEnv("ZEBPAY_SPOT_BASE_URL");
|
|
46
|
+
const futuresBaseUrl = getRequiredEnv("ZEBPAY_FUTURES_BASE_URL");
|
|
47
|
+
const marketBaseUrl = getRequiredEnv("ZEBPAY_MARKET_BASE_URL");
|
|
48
|
+
const transports = parseTransports(process.env.MCP_TRANSPORTS);
|
|
49
|
+
const logLevel = parseLogLevel(process.env.LOG_LEVEL);
|
|
50
|
+
const logFile = process.env.LOG_FILE; // Optional log file path
|
|
51
|
+
const timeoutMs = Number(process.env.HTTP_TIMEOUT_MS ?? 15000);
|
|
52
|
+
const retryCount = Number(process.env.HTTP_RETRY_COUNT ?? 2);
|
|
53
|
+
const signingHeaders = SIGNING_HEADERS;
|
|
54
|
+
if (!spotBaseUrl.startsWith("http")) {
|
|
55
|
+
throw new Error("Invalid spot base URL");
|
|
56
|
+
}
|
|
57
|
+
if (!futuresBaseUrl.startsWith("http")) {
|
|
58
|
+
throw new Error("Invalid futures base URL");
|
|
59
|
+
}
|
|
60
|
+
if (!marketBaseUrl.startsWith("http")) {
|
|
61
|
+
throw new Error("Invalid market base URL");
|
|
62
|
+
}
|
|
63
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
64
|
+
throw new Error("Invalid HTTP_TIMEOUT_MS");
|
|
65
|
+
}
|
|
66
|
+
if (!Number.isFinite(retryCount) || retryCount < 0) {
|
|
67
|
+
throw new Error("Invalid HTTP_RETRY_COUNT");
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
spotBaseUrl,
|
|
71
|
+
futuresBaseUrl,
|
|
72
|
+
marketBaseUrl,
|
|
73
|
+
transports,
|
|
74
|
+
logLevel,
|
|
75
|
+
logFile,
|
|
76
|
+
signingHeaders,
|
|
77
|
+
timeoutMs,
|
|
78
|
+
retryCount,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAUF,MAAM,eAAe,GAAuB;IAC1C,YAAY,EAAE,eAAe;IAC7B,eAAe,EAAE,kBAAkB;IACnC,eAAe,EAAE,EAAE;CACpB,CAAC;AAcF,MAAM,UAAU,MAAM,CAAC,KAAgC,EAAE,OAAe,CAAC;IACvE,IAAI,CAAC,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CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO;QACL,WAAW;QACX,cAAc;QACd,aAAa;QACb,UAAU;QACV,QAAQ;QACR,OAAO;QACP,cAAc;QACd,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface HttpRequestOptions {
|
|
2
|
+
method: string;
|
|
3
|
+
url: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
body?: unknown;
|
|
6
|
+
timeoutMs: number;
|
|
7
|
+
retryCount: number;
|
|
8
|
+
}
|
|
9
|
+
export interface HttpResponse<T = unknown> {
|
|
10
|
+
status: number;
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
data: T;
|
|
13
|
+
}
|
|
14
|
+
export declare class HttpError extends Error {
|
|
15
|
+
readonly status: number;
|
|
16
|
+
readonly details?: unknown;
|
|
17
|
+
readonly isHtmlResponse?: boolean;
|
|
18
|
+
constructor(message: string, status: number, details?: unknown, isHtmlResponse?: boolean);
|
|
19
|
+
}
|
|
20
|
+
export declare class HttpClient {
|
|
21
|
+
private readonly logLevel;
|
|
22
|
+
constructor(logLevel?: "debug" | "info" | "warn" | "error");
|
|
23
|
+
request<T = unknown>(opts: HttpRequestOptions): Promise<HttpResponse<T>>;
|
|
24
|
+
/**
|
|
25
|
+
* Sanitizes stack traces by removing file paths, keeping only function names and line numbers
|
|
26
|
+
*/
|
|
27
|
+
private sanitizeStack;
|
|
28
|
+
/**
|
|
29
|
+
* Formats response body to be more user-readable
|
|
30
|
+
*/
|
|
31
|
+
private formatResponseBody;
|
|
32
|
+
/**
|
|
33
|
+
* Sanitizes headers to redact sensitive information
|
|
34
|
+
*/
|
|
35
|
+
private sanitizeHeaders;
|
|
36
|
+
/**
|
|
37
|
+
* Sanitizes body to prevent logging huge payloads
|
|
38
|
+
*/
|
|
39
|
+
private sanitizeBody;
|
|
40
|
+
}
|