hooktunnel-cli 0.1.0
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/README.md +404 -0
- package/dist/commands/connect.d.ts +11 -0
- package/dist/commands/connect.d.ts.map +1 -0
- package/dist/commands/connect.js +59 -0
- package/dist/commands/connect.js.map +1 -0
- package/dist/commands/hooks.d.ts +6 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +51 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/login.d.ts +10 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +36 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +6 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +16 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/logs.d.ts +10 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +64 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/replay.d.ts +10 -0
- package/dist/commands/replay.d.ts.map +1 -0
- package/dist/commands/replay.js +43 -0
- package/dist/commands/replay.js.map +1 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +56 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +120 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +12 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +75 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +24 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +44 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/errors.d.ts +14 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +97 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/tunnel.d.ts +30 -0
- package/dist/lib/tunnel.d.ts.map +1 -0
- package/dist/lib/tunnel.js +237 -0
- package/dist/lib/tunnel.js.map +1 -0
- package/dist/types/api.d.ts +47 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +5 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/tunnel.d.ts +82 -0
- package/dist/types/tunnel.d.ts.map +1 -0
- package/dist/types/tunnel.js +6 -0
- package/dist/types/tunnel.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAqB1B,MAAM,UAAU,GAAiC;IAC/C,aAAa,EAAE;QACb,OAAO,EAAE,yBAAyB;QAClC,UAAU,EAAE,wCAAwC;KACrD;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,iBAAiB;QAC1B,UAAU,EAAE,0DAA0D;KACvE;IACD,iBAAiB,EAAE;QACjB,OAAO,EAAE,iCAAiC;QAC1C,UAAU,EAAE,8CAA8C;KAC3D;IACD,eAAe,EAAE;QACf,OAAO,EAAE,iBAAiB;QAC1B,UAAU,EAAE,4BAA4B;KACzC;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,cAAc;QACvB,UAAU,EAAE,4CAA4C;KACzD;IACD,SAAS,EAAE;QACT,OAAO,EAAE,oBAAoB;QAC7B,UAAU,EAAE,wDAAwD;KACrE;IACD,cAAc,EAAE;QACd,OAAO,EAAE,gBAAgB;QACzB,UAAU,EAAE,2CAA2C;KACxD;IACD,aAAa,EAAE;QACb,OAAO,EAAE,uBAAuB;QAChC,UAAU,EAAE,6CAA6C;KAC1D;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,mBAAmB;QAC5B,UAAU,EAAE,4CAA4C;KACzD;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,qBAAqB;QAC9B,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KAAK,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACtD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACnD,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAAC,eAAe,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tunnel Client
|
|
3
|
+
* CLI-CONN-001: WebSocket connection
|
|
4
|
+
* CLI-CONN-002: Forward to localhost
|
|
5
|
+
* CLI-CONN-003: Heartbeat handling
|
|
6
|
+
* CLI-CONN-004: Real-time log display
|
|
7
|
+
*/
|
|
8
|
+
import type { TunnelOptions, ConnectionState, RequestLogEntry } from '../types/tunnel.js';
|
|
9
|
+
export declare class TunnelClient {
|
|
10
|
+
private ws;
|
|
11
|
+
private state;
|
|
12
|
+
private options;
|
|
13
|
+
private sessionId;
|
|
14
|
+
private reconnectAttempt;
|
|
15
|
+
private clientInstanceId;
|
|
16
|
+
private requestLog;
|
|
17
|
+
constructor(options: TunnelOptions);
|
|
18
|
+
connect(): Promise<void>;
|
|
19
|
+
private sendHello;
|
|
20
|
+
private handleMessage;
|
|
21
|
+
private handleRequest;
|
|
22
|
+
private logRequest;
|
|
23
|
+
private sendPong;
|
|
24
|
+
private attemptReconnect;
|
|
25
|
+
disconnect(): void;
|
|
26
|
+
getState(): ConnectionState;
|
|
27
|
+
getSessionId(): string | null;
|
|
28
|
+
getRequestLog(): RequestLogEntry[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=tunnel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnel.d.ts","sourceRoot":"","sources":["../../src/lib/tunnel.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAMf,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAM5B,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,UAAU,CAAyB;gBAE/B,OAAO,EAAE,aAAa;IAK5B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqD9B,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,aAAa;YAyCP,aAAa;IA6D3B,OAAO,CAAC,UAAU;IAkClB,OAAO,CAAC,QAAQ;IAYhB,OAAO,CAAC,gBAAgB;IAoBxB,UAAU,IAAI,IAAI;IAQlB,QAAQ,IAAI,eAAe;IAI3B,YAAY,IAAI,MAAM,GAAG,IAAI;IAI7B,aAAa,IAAI,eAAe,EAAE;CAGnC"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tunnel Client
|
|
3
|
+
* CLI-CONN-001: WebSocket connection
|
|
4
|
+
* CLI-CONN-002: Forward to localhost
|
|
5
|
+
* CLI-CONN-003: Heartbeat handling
|
|
6
|
+
* CLI-CONN-004: Real-time log display
|
|
7
|
+
*/
|
|
8
|
+
import WebSocket from 'ws';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
11
|
+
import { getTunnelUrl } from './config.js';
|
|
12
|
+
import { CLIError } from './errors.js';
|
|
13
|
+
const CLIENT_VERSION = '0.1.0';
|
|
14
|
+
const RECONNECT_DELAYS = [1000, 2000, 5000, 10000, 30000];
|
|
15
|
+
// Default tunnel endpoint: wss://tunnel.hooktunnel.com/ws/tunnel
|
|
16
|
+
export class TunnelClient {
|
|
17
|
+
ws = null;
|
|
18
|
+
state = 'disconnected';
|
|
19
|
+
options;
|
|
20
|
+
sessionId = null;
|
|
21
|
+
reconnectAttempt = 0;
|
|
22
|
+
clientInstanceId;
|
|
23
|
+
requestLog = [];
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.options = options;
|
|
26
|
+
this.clientInstanceId = uuidv4();
|
|
27
|
+
}
|
|
28
|
+
async connect() {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
this.state = 'connecting';
|
|
31
|
+
const tunnelUrl = getTunnelUrl();
|
|
32
|
+
if (this.options.verbose) {
|
|
33
|
+
console.log(chalk.gray(`[DEBUG] Connecting to ${tunnelUrl}`));
|
|
34
|
+
}
|
|
35
|
+
this.ws = new WebSocket(tunnelUrl, {
|
|
36
|
+
headers: {
|
|
37
|
+
'Authorization': `Bearer ${this.options.apiKey}`,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
this.ws.on('open', () => {
|
|
41
|
+
if (this.options.verbose) {
|
|
42
|
+
console.log(chalk.gray('[DEBUG] WebSocket connected, sending hello'));
|
|
43
|
+
}
|
|
44
|
+
this.sendHello();
|
|
45
|
+
});
|
|
46
|
+
this.ws.on('message', (data) => {
|
|
47
|
+
try {
|
|
48
|
+
const message = JSON.parse(data.toString());
|
|
49
|
+
this.handleMessage(message, resolve, reject);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(chalk.red('Failed to parse message'));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
this.ws.on('close', (code, reason) => {
|
|
56
|
+
const wasConnected = this.state === 'connected';
|
|
57
|
+
this.state = 'disconnected';
|
|
58
|
+
if (wasConnected) {
|
|
59
|
+
console.log(chalk.yellow(`\nConnection closed (${code}): ${reason.toString()}`));
|
|
60
|
+
this.attemptReconnect();
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
reject(new CLIError('CONNECTION_FAILED', `Code: ${code}`));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this.ws.on('error', (error) => {
|
|
67
|
+
if (this.state === 'connecting') {
|
|
68
|
+
reject(new CLIError('CONNECTION_FAILED', error.message));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.error(chalk.red(`Connection error: ${error.message}`));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
sendHello() {
|
|
77
|
+
const hello = {
|
|
78
|
+
type: 'hello',
|
|
79
|
+
client_instance_id: this.clientInstanceId,
|
|
80
|
+
env: this.options.env,
|
|
81
|
+
local_base_url: `http://${this.options.host || 'localhost'}:${this.options.port}`,
|
|
82
|
+
capabilities: {
|
|
83
|
+
max_inflight: 50,
|
|
84
|
+
max_body_bytes: 10 * 1024 * 1024, // 10MB
|
|
85
|
+
supports_gzip: false,
|
|
86
|
+
},
|
|
87
|
+
client_version: CLIENT_VERSION,
|
|
88
|
+
};
|
|
89
|
+
this.ws?.send(JSON.stringify(hello));
|
|
90
|
+
}
|
|
91
|
+
handleMessage(message, resolveConnect, rejectConnect) {
|
|
92
|
+
switch (message.type) {
|
|
93
|
+
case 'hello_ack':
|
|
94
|
+
this.state = 'connected';
|
|
95
|
+
this.sessionId = message.tunnel_session_id;
|
|
96
|
+
this.reconnectAttempt = 0;
|
|
97
|
+
if (this.options.verbose) {
|
|
98
|
+
console.log(chalk.gray(`[DEBUG] Session established: ${this.sessionId}`));
|
|
99
|
+
console.log(chalk.gray(`[DEBUG] Policies: ${JSON.stringify(message.policies)}`));
|
|
100
|
+
}
|
|
101
|
+
console.log(chalk.green('✓ Connected to HookTunnel'));
|
|
102
|
+
console.log(chalk.gray(` Session: ${this.sessionId?.slice(0, 8)}...`));
|
|
103
|
+
console.log(chalk.gray(` Forwarding to: http://${this.options.host || 'localhost'}:${this.options.port}`));
|
|
104
|
+
console.log();
|
|
105
|
+
resolveConnect?.();
|
|
106
|
+
break;
|
|
107
|
+
case 'request':
|
|
108
|
+
this.handleRequest(message);
|
|
109
|
+
break;
|
|
110
|
+
case 'ping':
|
|
111
|
+
this.sendPong(message.timestamp);
|
|
112
|
+
break;
|
|
113
|
+
case 'error':
|
|
114
|
+
console.error(chalk.red(`Server error: ${message.message}`));
|
|
115
|
+
if (message.code === 'AUTH_FAILED') {
|
|
116
|
+
rejectConnect?.(new CLIError('AUTH_INVALID'));
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async handleRequest(request) {
|
|
122
|
+
const startTime = Date.now();
|
|
123
|
+
if (this.options.verbose) {
|
|
124
|
+
console.log(chalk.gray(`[DEBUG] Received request: ${request.request_id}`));
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
// Forward to local server
|
|
128
|
+
const localUrl = `http://${this.options.host || 'localhost'}:${this.options.port}${request.path}${request.query ? '?' + request.query : ''}`;
|
|
129
|
+
const headers = { ...request.headers };
|
|
130
|
+
delete headers['host'];
|
|
131
|
+
delete headers['connection'];
|
|
132
|
+
const response = await fetch(localUrl, {
|
|
133
|
+
method: request.method,
|
|
134
|
+
headers,
|
|
135
|
+
body: request.body_base64 ? Buffer.from(request.body_base64, 'base64') : undefined,
|
|
136
|
+
});
|
|
137
|
+
const duration = Date.now() - startTime;
|
|
138
|
+
const responseHeaders = {};
|
|
139
|
+
response.headers.forEach((value, key) => {
|
|
140
|
+
responseHeaders[key] = value;
|
|
141
|
+
});
|
|
142
|
+
const responseBody = await response.arrayBuffer();
|
|
143
|
+
// Send response back
|
|
144
|
+
const responseMsg = {
|
|
145
|
+
type: 'response',
|
|
146
|
+
request_id: request.request_id,
|
|
147
|
+
status: response.status,
|
|
148
|
+
headers: responseHeaders,
|
|
149
|
+
body_base64: Buffer.from(responseBody).toString('base64'),
|
|
150
|
+
};
|
|
151
|
+
this.ws?.send(JSON.stringify(responseMsg));
|
|
152
|
+
// Log the request
|
|
153
|
+
this.logRequest(request, response.status, duration);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
const duration = Date.now() - startTime;
|
|
157
|
+
// Send error response
|
|
158
|
+
const responseMsg = {
|
|
159
|
+
type: 'response',
|
|
160
|
+
request_id: request.request_id,
|
|
161
|
+
status: 502,
|
|
162
|
+
headers: { 'content-type': 'text/plain' },
|
|
163
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
164
|
+
};
|
|
165
|
+
this.ws?.send(JSON.stringify(responseMsg));
|
|
166
|
+
// Log the error
|
|
167
|
+
this.logRequest(request, 502, duration, true);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
logRequest(request, status, duration, isError = false) {
|
|
171
|
+
const time = new Date().toLocaleTimeString();
|
|
172
|
+
const method = request.method.padEnd(6);
|
|
173
|
+
const path = request.path.length > 40 ? request.path.slice(0, 37) + '...' : request.path;
|
|
174
|
+
let statusColor = chalk.green;
|
|
175
|
+
if (status >= 400 && status < 500)
|
|
176
|
+
statusColor = chalk.yellow;
|
|
177
|
+
if (status >= 500 || isError)
|
|
178
|
+
statusColor = chalk.red;
|
|
179
|
+
const methodColor = request.method === 'GET' ? chalk.blue :
|
|
180
|
+
request.method === 'POST' ? chalk.green :
|
|
181
|
+
request.method === 'PUT' ? chalk.yellow :
|
|
182
|
+
request.method === 'DELETE' ? chalk.red :
|
|
183
|
+
chalk.gray;
|
|
184
|
+
console.log(chalk.gray(`[${time}]`), methodColor(method), chalk.white(path), statusColor(`${status}`), chalk.gray(`(${duration}ms)`));
|
|
185
|
+
this.requestLog.push({
|
|
186
|
+
id: request.request_id,
|
|
187
|
+
method: request.method,
|
|
188
|
+
path: request.path,
|
|
189
|
+
status,
|
|
190
|
+
duration,
|
|
191
|
+
timestamp: new Date(),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
sendPong(timestamp) {
|
|
195
|
+
const pong = {
|
|
196
|
+
type: 'pong',
|
|
197
|
+
timestamp,
|
|
198
|
+
};
|
|
199
|
+
this.ws?.send(JSON.stringify(pong));
|
|
200
|
+
if (this.options.verbose) {
|
|
201
|
+
console.log(chalk.gray('[DEBUG] Sent pong'));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
attemptReconnect() {
|
|
205
|
+
if (this.reconnectAttempt >= RECONNECT_DELAYS.length) {
|
|
206
|
+
console.error(chalk.red('Max reconnection attempts reached. Exiting.'));
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
const delay = RECONNECT_DELAYS[this.reconnectAttempt];
|
|
210
|
+
this.reconnectAttempt++;
|
|
211
|
+
this.state = 'reconnecting';
|
|
212
|
+
console.log(chalk.yellow(`Reconnecting in ${delay / 1000}s... (attempt ${this.reconnectAttempt})`));
|
|
213
|
+
setTimeout(() => {
|
|
214
|
+
this.connect().catch((error) => {
|
|
215
|
+
console.error(chalk.red(`Reconnection failed: ${error.message}`));
|
|
216
|
+
this.attemptReconnect();
|
|
217
|
+
});
|
|
218
|
+
}, delay);
|
|
219
|
+
}
|
|
220
|
+
disconnect() {
|
|
221
|
+
if (this.ws) {
|
|
222
|
+
this.ws.close(1000, 'Client disconnecting');
|
|
223
|
+
this.ws = null;
|
|
224
|
+
}
|
|
225
|
+
this.state = 'disconnected';
|
|
226
|
+
}
|
|
227
|
+
getState() {
|
|
228
|
+
return this.state;
|
|
229
|
+
}
|
|
230
|
+
getSessionId() {
|
|
231
|
+
return this.sessionId;
|
|
232
|
+
}
|
|
233
|
+
getRequestLog() {
|
|
234
|
+
return this.requestLog;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=tunnel.js.map
|
|
@@ -0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OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAClE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;IAED,UAAU;QACR,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;YAC5C,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC;IAC9B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Response Types
|
|
3
|
+
*/
|
|
4
|
+
export interface Hook {
|
|
5
|
+
id: string;
|
|
6
|
+
hook_id: string;
|
|
7
|
+
provider: 'generic' | 'twilio' | 'stripe';
|
|
8
|
+
env: string;
|
|
9
|
+
status: 'active' | 'paused' | 'deleted';
|
|
10
|
+
created_at: string;
|
|
11
|
+
request_count: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RequestLog {
|
|
14
|
+
id: string;
|
|
15
|
+
hook_id: string;
|
|
16
|
+
method: string;
|
|
17
|
+
path: string;
|
|
18
|
+
content_type: string | null;
|
|
19
|
+
body_size: number;
|
|
20
|
+
response_status: number;
|
|
21
|
+
received_at: string;
|
|
22
|
+
body_redacted: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface HooksResponse {
|
|
25
|
+
hooks: Hook[];
|
|
26
|
+
}
|
|
27
|
+
export interface LogsResponse {
|
|
28
|
+
logs: RequestLog[];
|
|
29
|
+
total: number;
|
|
30
|
+
limit: number;
|
|
31
|
+
offset: number;
|
|
32
|
+
hasMore: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ReplayResponse {
|
|
35
|
+
success: boolean;
|
|
36
|
+
replay: {
|
|
37
|
+
id: string;
|
|
38
|
+
status: string;
|
|
39
|
+
responseStatus: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface UserInfo {
|
|
43
|
+
id: string;
|
|
44
|
+
email: string;
|
|
45
|
+
tier: string;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QACN,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tunnel Protocol Types
|
|
3
|
+
* Based on ngrokky tunnel gateway protocol
|
|
4
|
+
*/
|
|
5
|
+
export type Environment = 'dev' | 'staging' | 'prod';
|
|
6
|
+
export interface HelloMessage {
|
|
7
|
+
type: 'hello';
|
|
8
|
+
client_instance_id: string;
|
|
9
|
+
env: Environment;
|
|
10
|
+
local_base_url: string;
|
|
11
|
+
capabilities: {
|
|
12
|
+
max_inflight: number;
|
|
13
|
+
max_body_bytes: number;
|
|
14
|
+
supports_gzip: boolean;
|
|
15
|
+
};
|
|
16
|
+
client_version: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ResponseMessage {
|
|
19
|
+
type: 'response';
|
|
20
|
+
request_id: string;
|
|
21
|
+
status: number;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
body_base64?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PongMessage {
|
|
27
|
+
type: 'pong';
|
|
28
|
+
timestamp: string;
|
|
29
|
+
}
|
|
30
|
+
export type ClientMessage = HelloMessage | ResponseMessage | PongMessage;
|
|
31
|
+
export interface HelloAckMessage {
|
|
32
|
+
type: 'hello_ack';
|
|
33
|
+
tunnel_session_id: string;
|
|
34
|
+
tenant_id: string;
|
|
35
|
+
env: Environment;
|
|
36
|
+
policies: {
|
|
37
|
+
idle_timeout_seconds: number;
|
|
38
|
+
ping_interval_seconds: number;
|
|
39
|
+
max_inflight_enforced: number;
|
|
40
|
+
max_body_bytes_enforced: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface RequestMessage {
|
|
44
|
+
type: 'request';
|
|
45
|
+
request_id: string;
|
|
46
|
+
hook_id: string;
|
|
47
|
+
method: string;
|
|
48
|
+
path: string;
|
|
49
|
+
query: string;
|
|
50
|
+
headers: Record<string, string>;
|
|
51
|
+
body_base64?: string;
|
|
52
|
+
received_at: string;
|
|
53
|
+
remote_ip: string;
|
|
54
|
+
provider: string;
|
|
55
|
+
}
|
|
56
|
+
export interface PingMessage {
|
|
57
|
+
type: 'ping';
|
|
58
|
+
timestamp: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ErrorMessage {
|
|
61
|
+
type: 'error';
|
|
62
|
+
code: string;
|
|
63
|
+
message: string;
|
|
64
|
+
}
|
|
65
|
+
export type ServerMessage = HelloAckMessage | RequestMessage | PingMessage | ErrorMessage;
|
|
66
|
+
export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
67
|
+
export interface TunnelOptions {
|
|
68
|
+
env: Environment;
|
|
69
|
+
port: number;
|
|
70
|
+
host?: string;
|
|
71
|
+
verbose?: boolean;
|
|
72
|
+
apiKey: string;
|
|
73
|
+
}
|
|
74
|
+
export interface RequestLogEntry {
|
|
75
|
+
id: string;
|
|
76
|
+
method: string;
|
|
77
|
+
path: string;
|
|
78
|
+
status: number;
|
|
79
|
+
duration: number;
|
|
80
|
+
timestamp: Date;
|
|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{"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../src/types/tunnel.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hooktunnel-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for HookTunnel - Forward webhooks to localhost",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"hooktunnel": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsx src/index.ts",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest",
|
|
14
|
+
"test:contracts": "vitest run tests/contracts/",
|
|
15
|
+
"lint": "eslint src/",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"webhook",
|
|
21
|
+
"tunnel",
|
|
22
|
+
"ngrok",
|
|
23
|
+
"development",
|
|
24
|
+
"debugging"
|
|
25
|
+
],
|
|
26
|
+
"author": "HookTunnel",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/Hulupeep/hooktunnel-cli.git"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@types/uuid": "^10.0.0",
|
|
41
|
+
"chalk": "^5.3.0",
|
|
42
|
+
"commander": "^12.1.0",
|
|
43
|
+
"conf": "^13.0.1",
|
|
44
|
+
"ora": "^8.0.1",
|
|
45
|
+
"uuid": "^13.0.0",
|
|
46
|
+
"ws": "^8.18.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^20.10.0",
|
|
50
|
+
"@types/ws": "^8.5.10",
|
|
51
|
+
"tsx": "^4.7.0",
|
|
52
|
+
"typescript": "^5.3.0",
|
|
53
|
+
"vitest": "^1.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|