recker 1.0.19 → 1.0.20-next.963881c

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.
@@ -0,0 +1,78 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { WebSocket, type RawData } from 'ws';
3
+ export interface MockWebSocketServerOptions {
4
+ port?: number;
5
+ host?: string;
6
+ path?: string;
7
+ echo?: boolean;
8
+ delay?: number;
9
+ protocols?: string[];
10
+ autoCloseAfter?: number;
11
+ dropRate?: number;
12
+ maxConnections?: number;
13
+ }
14
+ export interface MockWebSocketClient {
15
+ id: string;
16
+ socket: WebSocket;
17
+ connectedAt: number;
18
+ messageCount: number;
19
+ lastMessage?: RawData;
20
+ metadata: Record<string, any>;
21
+ }
22
+ export interface MockWebSocketMessage {
23
+ clientId: string;
24
+ data: RawData;
25
+ timestamp: number;
26
+ isBinary: boolean;
27
+ }
28
+ export interface MockWebSocketStats {
29
+ totalConnections: number;
30
+ currentConnections: number;
31
+ totalMessages: number;
32
+ totalBytesSent: number;
33
+ totalBytesReceived: number;
34
+ messageLog: MockWebSocketMessage[];
35
+ }
36
+ export declare class MockWebSocketServer extends EventEmitter {
37
+ private options;
38
+ private httpServer;
39
+ private wss;
40
+ private clients;
41
+ private responses;
42
+ private _port;
43
+ private _started;
44
+ private clientIdCounter;
45
+ private stats;
46
+ constructor(options?: MockWebSocketServerOptions);
47
+ get port(): number;
48
+ get address(): string;
49
+ get url(): string;
50
+ get isRunning(): boolean;
51
+ get connectionCount(): number;
52
+ get statistics(): MockWebSocketStats;
53
+ get allClients(): MockWebSocketClient[];
54
+ start(): Promise<void>;
55
+ stop(): Promise<void>;
56
+ reset(): void;
57
+ setResponse(pattern: string | RegExp, response: string | Buffer | ((msg: string, client: MockWebSocketClient) => string | Buffer | null)): void;
58
+ clearResponses(): void;
59
+ setEcho(enabled: boolean): void;
60
+ setDelay(delay: number): void;
61
+ setDropRate(rate: number): void;
62
+ getClient(id: string): MockWebSocketClient | undefined;
63
+ disconnectClient(id: string, code?: number, reason?: string): void;
64
+ disconnectAll(code?: number, reason?: string): void;
65
+ send(clientId: string, data: string | Buffer | object): boolean;
66
+ broadcast(data: string | Buffer | object): number;
67
+ sendToAll(data: string | Buffer | object): number;
68
+ simulateMessage(clientId: string, data: string | Buffer): void;
69
+ ping(clientId?: string): void;
70
+ waitForConnections(count: number, timeout?: number): Promise<MockWebSocketClient[]>;
71
+ waitForMessages(count: number, timeout?: number): Promise<MockWebSocketMessage[]>;
72
+ private handleConnection;
73
+ private handleMessage;
74
+ private getResponse;
75
+ static create(options?: MockWebSocketServerOptions): Promise<MockWebSocketServer>;
76
+ }
77
+ export declare function createMockWebSocketServer(responses?: Record<string, string>, options?: MockWebSocketServerOptions): Promise<MockWebSocketServer>;
78
+ //# sourceMappingURL=mock-websocket-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-websocket-server.d.ts","sourceRoot":"","sources":["../../src/testing/mock-websocket-server.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAmB,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC;AAO9D,MAAM,WAAW,0BAA0B;IAKzC,IAAI,CAAC,EAAE,MAAM,CAAC;IAMd,IAAI,CAAC,EAAE,MAAM,CAAC;IAMd,IAAI,CAAC,EAAE,MAAM,CAAC;IAMd,IAAI,CAAC,EAAE,OAAO,CAAC;IAMf,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAMrB,cAAc,CAAC,EAAE,MAAM,CAAC;IAMxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAMlB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;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AAO,CAAC,WAAW;WAwBN,MAAM,CAAC,OAAO,GAAE,0BAA+B,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAK5F;AASD,wBAAsB,yBAAyB,CAC7C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAY9B"}
@@ -0,0 +1,316 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { WebSocketServer, WebSocket } from 'ws';
3
+ import { createServer } from 'node:http';
4
+ export class MockWebSocketServer extends EventEmitter {
5
+ options;
6
+ httpServer = null;
7
+ wss = null;
8
+ clients = new Map();
9
+ responses = new Map();
10
+ _port = 0;
11
+ _started = false;
12
+ clientIdCounter = 0;
13
+ stats = {
14
+ totalConnections: 0,
15
+ currentConnections: 0,
16
+ totalMessages: 0,
17
+ totalBytesSent: 0,
18
+ totalBytesReceived: 0,
19
+ messageLog: [],
20
+ };
21
+ constructor(options = {}) {
22
+ super();
23
+ this.options = {
24
+ port: 0,
25
+ host: '127.0.0.1',
26
+ path: '/',
27
+ echo: true,
28
+ delay: 0,
29
+ protocols: [],
30
+ autoCloseAfter: 0,
31
+ dropRate: 0,
32
+ maxConnections: 0,
33
+ ...options,
34
+ };
35
+ }
36
+ get port() {
37
+ return this._port;
38
+ }
39
+ get address() {
40
+ return this.options.host;
41
+ }
42
+ get url() {
43
+ return `ws://${this.options.host}:${this._port}${this.options.path}`;
44
+ }
45
+ get isRunning() {
46
+ return this._started;
47
+ }
48
+ get connectionCount() {
49
+ return this.clients.size;
50
+ }
51
+ get statistics() {
52
+ return { ...this.stats };
53
+ }
54
+ get allClients() {
55
+ return [...this.clients.values()];
56
+ }
57
+ async start() {
58
+ if (this._started) {
59
+ throw new Error('Server already started');
60
+ }
61
+ return new Promise((resolve, reject) => {
62
+ this.httpServer = createServer();
63
+ this.wss = new WebSocketServer({
64
+ server: this.httpServer,
65
+ path: this.options.path,
66
+ handleProtocols: this.options.protocols.length > 0
67
+ ? (protocols) => {
68
+ for (const p of protocols) {
69
+ if (this.options.protocols.includes(p)) {
70
+ return p;
71
+ }
72
+ }
73
+ return false;
74
+ }
75
+ : undefined,
76
+ });
77
+ this.wss.on('connection', (socket, req) => this.handleConnection(socket, req));
78
+ this.wss.on('error', (err) => this.emit('error', err));
79
+ this.httpServer.on('error', reject);
80
+ this.httpServer.listen(this.options.port, this.options.host, () => {
81
+ const addr = this.httpServer.address();
82
+ this._port = typeof addr === 'string' ? 0 : addr?.port ?? 0;
83
+ this._started = true;
84
+ this.emit('listening', this._port);
85
+ resolve();
86
+ });
87
+ });
88
+ }
89
+ async stop() {
90
+ if (!this._started)
91
+ return;
92
+ for (const client of this.clients.values()) {
93
+ client.socket.close(1001, 'Server shutting down');
94
+ }
95
+ this.clients.clear();
96
+ return new Promise((resolve) => {
97
+ this.wss?.close(() => {
98
+ this.httpServer?.close(() => {
99
+ this._started = false;
100
+ this.wss = null;
101
+ this.httpServer = null;
102
+ this.emit('close');
103
+ resolve();
104
+ });
105
+ });
106
+ });
107
+ }
108
+ reset() {
109
+ this.responses.clear();
110
+ this.stats = {
111
+ totalConnections: 0,
112
+ currentConnections: 0,
113
+ totalMessages: 0,
114
+ totalBytesSent: 0,
115
+ totalBytesReceived: 0,
116
+ messageLog: [],
117
+ };
118
+ this.options.echo = true;
119
+ this.options.delay = 0;
120
+ this.options.dropRate = 0;
121
+ this.emit('reset');
122
+ }
123
+ setResponse(pattern, response) {
124
+ const key = pattern instanceof RegExp ? pattern.source : pattern;
125
+ this.responses.set(key, response);
126
+ }
127
+ clearResponses() {
128
+ this.responses.clear();
129
+ }
130
+ setEcho(enabled) {
131
+ this.options.echo = enabled;
132
+ }
133
+ setDelay(delay) {
134
+ this.options.delay = delay;
135
+ }
136
+ setDropRate(rate) {
137
+ this.options.dropRate = Math.max(0, Math.min(1, rate));
138
+ }
139
+ getClient(id) {
140
+ return this.clients.get(id);
141
+ }
142
+ disconnectClient(id, code = 1000, reason = 'Disconnected by server') {
143
+ const client = this.clients.get(id);
144
+ if (client) {
145
+ client.socket.close(code, reason);
146
+ }
147
+ }
148
+ disconnectAll(code = 1000, reason = 'Disconnected by server') {
149
+ for (const client of this.clients.values()) {
150
+ client.socket.close(code, reason);
151
+ }
152
+ }
153
+ send(clientId, data) {
154
+ const client = this.clients.get(clientId);
155
+ if (!client || client.socket.readyState !== WebSocket.OPEN) {
156
+ return false;
157
+ }
158
+ const message = typeof data === 'object' && !Buffer.isBuffer(data)
159
+ ? JSON.stringify(data)
160
+ : data;
161
+ client.socket.send(message);
162
+ this.stats.totalBytesSent += Buffer.byteLength(message);
163
+ return true;
164
+ }
165
+ broadcast(data) {
166
+ let sent = 0;
167
+ for (const client of this.clients.values()) {
168
+ if (this.send(client.id, data)) {
169
+ sent++;
170
+ }
171
+ }
172
+ return sent;
173
+ }
174
+ sendToAll(data) {
175
+ return this.broadcast(data);
176
+ }
177
+ simulateMessage(clientId, data) {
178
+ const client = this.clients.get(clientId);
179
+ if (client) {
180
+ const rawData = Buffer.isBuffer(data) ? data : Buffer.from(data);
181
+ this.handleMessage(client, rawData, Buffer.isBuffer(data));
182
+ }
183
+ }
184
+ ping(clientId) {
185
+ if (clientId) {
186
+ const client = this.clients.get(clientId);
187
+ client?.socket.ping();
188
+ }
189
+ else {
190
+ for (const client of this.clients.values()) {
191
+ client.socket.ping();
192
+ }
193
+ }
194
+ }
195
+ async waitForConnections(count, timeout = 5000) {
196
+ const start = Date.now();
197
+ while (this.clients.size < count) {
198
+ if (Date.now() - start > timeout) {
199
+ throw new Error(`Timeout waiting for ${count} connections (have ${this.clients.size})`);
200
+ }
201
+ await new Promise((resolve) => setTimeout(resolve, 10));
202
+ }
203
+ return [...this.clients.values()].slice(0, count);
204
+ }
205
+ async waitForMessages(count, timeout = 5000) {
206
+ const start = Date.now();
207
+ while (this.stats.messageLog.length < count) {
208
+ if (Date.now() - start > timeout) {
209
+ throw new Error(`Timeout waiting for ${count} messages (have ${this.stats.messageLog.length})`);
210
+ }
211
+ await new Promise((resolve) => setTimeout(resolve, 10));
212
+ }
213
+ return this.stats.messageLog.slice(0, count);
214
+ }
215
+ handleConnection(socket, _req) {
216
+ if (this.options.maxConnections > 0 && this.clients.size >= this.options.maxConnections) {
217
+ socket.close(1013, 'Max connections reached');
218
+ return;
219
+ }
220
+ if (this.options.dropRate > 0 && Math.random() < this.options.dropRate) {
221
+ socket.close(1006, 'Connection dropped');
222
+ this.emit('dropped');
223
+ return;
224
+ }
225
+ const clientId = `client-${++this.clientIdCounter}`;
226
+ const client = {
227
+ id: clientId,
228
+ socket,
229
+ connectedAt: Date.now(),
230
+ messageCount: 0,
231
+ metadata: {},
232
+ };
233
+ this.clients.set(clientId, client);
234
+ this.stats.totalConnections++;
235
+ this.stats.currentConnections++;
236
+ this.emit('connection', client);
237
+ if (this.options.autoCloseAfter > 0) {
238
+ setTimeout(() => {
239
+ if (socket.readyState === WebSocket.OPEN) {
240
+ socket.close(1000, 'Auto-close timeout');
241
+ }
242
+ }, this.options.autoCloseAfter);
243
+ }
244
+ socket.on('message', (data, isBinary) => {
245
+ this.handleMessage(client, data, isBinary);
246
+ });
247
+ socket.on('close', (code, reason) => {
248
+ this.clients.delete(clientId);
249
+ this.stats.currentConnections--;
250
+ this.emit('disconnect', client, code, reason.toString());
251
+ });
252
+ socket.on('error', (err) => {
253
+ this.emit('clientError', client, err);
254
+ });
255
+ socket.on('ping', () => {
256
+ this.emit('ping', client);
257
+ });
258
+ socket.on('pong', () => {
259
+ this.emit('pong', client);
260
+ });
261
+ }
262
+ async handleMessage(client, data, isBinary) {
263
+ const bytes = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data.toString());
264
+ this.stats.totalBytesReceived += bytes;
265
+ this.stats.totalMessages++;
266
+ client.messageCount++;
267
+ client.lastMessage = data;
268
+ const message = {
269
+ clientId: client.id,
270
+ data,
271
+ timestamp: Date.now(),
272
+ isBinary,
273
+ };
274
+ this.stats.messageLog.push(message);
275
+ this.emit('message', message, client);
276
+ if (this.options.delay > 0) {
277
+ await new Promise((resolve) => setTimeout(resolve, this.options.delay));
278
+ }
279
+ const response = this.getResponse(data.toString(), client);
280
+ if (response !== null && client.socket.readyState === WebSocket.OPEN) {
281
+ client.socket.send(response);
282
+ this.stats.totalBytesSent += Buffer.byteLength(response);
283
+ }
284
+ }
285
+ getResponse(msg, client) {
286
+ for (const [pattern, response] of this.responses) {
287
+ const regex = new RegExp(pattern);
288
+ if (regex.test(msg)) {
289
+ if (typeof response === 'function') {
290
+ return response(msg, client);
291
+ }
292
+ return response;
293
+ }
294
+ }
295
+ if (this.options.echo) {
296
+ return msg;
297
+ }
298
+ return null;
299
+ }
300
+ static async create(options = {}) {
301
+ const server = new MockWebSocketServer(options);
302
+ await server.start();
303
+ return server;
304
+ }
305
+ }
306
+ export async function createMockWebSocketServer(responses, options) {
307
+ const server = new MockWebSocketServer(options);
308
+ if (responses) {
309
+ for (const [pattern, response] of Object.entries(responses)) {
310
+ server.setResponse(pattern, response);
311
+ }
312
+ server.setEcho(false);
313
+ }
314
+ await server.start();
315
+ return server;
316
+ }
@@ -31,7 +31,7 @@ export declare class UndiciTransport implements Transport {
31
31
  private tlsOptions?;
32
32
  private socketClient?;
33
33
  private observability;
34
- constructor(baseUrl: string, options?: UndiciTransportOptions);
34
+ constructor(baseUrl?: string, options?: UndiciTransportOptions);
35
35
  dispatch(req: ReckerRequest): Promise<ReckerResponse>;
36
36
  private dispatchFast;
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../src/transport/undici.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAW,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAgB,UAAU,EAAkD,MAAM,mBAAmB,CAAC;AAOxN,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAwNzD,UAAU,sBAAsB;IAC9B,cAAc,CAAC,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U,CAAC,CAAa;IAChC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAU;gBAEnB,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B;IAmG5D,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;YAsV7C,YAAY;CAoQ3B"}
@@ -23,7 +23,7 @@ undiciRequestChannel.subscribe((message) => {
23
23
  });
24
24
  undiciBodySentChannel.subscribe((message) => {
25
25
  const store = requestStorage.getStore();
26
- if (store && store.hooks && store.hooks.onRequestSent) {
26
+ if (store?.hooks && store.hooks.onRequestSent) {
27
27
  store.hooks.onRequestSent();
28
28
  }
29
29
  });
@@ -143,7 +143,7 @@ export class UndiciTransport {
143
143
  socketClient;
144
144
  observability;
145
145
  constructor(baseUrl, options = {}) {
146
- this.baseUrl = baseUrl;
146
+ this.baseUrl = baseUrl || '';
147
147
  this.options = options;
148
148
  this.tlsOptions = options.tls;
149
149
  this.observability = options.observability !== false;
@@ -203,7 +203,7 @@ export class UndiciTransport {
203
203
  localAddress: options.localAddress,
204
204
  });
205
205
  }
206
- if (options.socketPath) {
206
+ if (options.socketPath && baseUrl) {
207
207
  this.socketClient = new Client(baseUrl, {
208
208
  socketPath: options.socketPath
209
209
  });
@@ -213,8 +213,14 @@ export class UndiciTransport {
213
213
  const headers = Object.fromEntries(req.headers);
214
214
  const contentLengthHeader = headers['content-length'];
215
215
  const uploadTotal = contentLengthHeader ? parseInt(contentLengthHeader, 10) : undefined;
216
- const path = req.url.startsWith(this.baseUrl) ? req.url.substring(this.baseUrl.length) : req.url;
217
- let currentUrl = new URL(path, this.baseUrl).toString();
216
+ let currentUrl;
217
+ if (this.baseUrl) {
218
+ const path = req.url.startsWith(this.baseUrl) ? req.url.substring(this.baseUrl.length) : req.url;
219
+ currentUrl = new URL(path, this.baseUrl).toString();
220
+ }
221
+ else {
222
+ currentUrl = req.url;
223
+ }
218
224
  const handleRedirectsManually = Boolean(req.beforeRedirect);
219
225
  const maxRedirects = req.maxRedirects ?? 20;
220
226
  const followRedirects = req.followRedirects !== false;
@@ -88,7 +88,7 @@ export async function getSecurityRecords(domain) {
88
88
  try {
89
89
  const dmarcRecords = await dns.resolveTxt(`_dmarc.${domain}`);
90
90
  const dmarcTxt = dmarcRecords.map(chunks => chunks.join(''))[0];
91
- if (dmarcTxt && dmarcTxt.startsWith('v=DMARC1')) {
91
+ if (dmarcTxt?.startsWith('v=DMARC1')) {
92
92
  results.dmarc = dmarcTxt;
93
93
  }
94
94
  }
package/dist/utils/dns.js CHANGED
@@ -3,7 +3,7 @@ import { promisify } from 'node:util';
3
3
  const lookupAsync = promisify(lookup);
4
4
  export function createLookupFunction(options) {
5
5
  return (hostname, opts, callback) => {
6
- if (options.override && options.override[hostname]) {
6
+ if (options.override?.[hostname]) {
7
7
  const ip = options.override[hostname];
8
8
  const family = ip.includes(':') ? 6 : 4;
9
9
  return callback(null, ip, family);
@@ -12,7 +12,7 @@ export function createLookupFunction(options) {
12
12
  };
13
13
  }
14
14
  export async function customDNSLookup(hostname, options = {}) {
15
- if (options.override && options.override[hostname]) {
15
+ if (options.override?.[hostname]) {
16
16
  const ip = options.override[hostname];
17
17
  const family = ip.includes(':') ? 6 : 4;
18
18
  return { address: ip, family };
@@ -55,7 +55,7 @@ export async function requireOptional(packageName, submodule) {
55
55
  const err = error;
56
56
  const isModuleNotFound = err.code === 'ERR_MODULE_NOT_FOUND' ||
57
57
  err.code === 'MODULE_NOT_FOUND' ||
58
- (err.message && err.message.includes('Cannot find module'));
58
+ (err.message?.includes('Cannot find module'));
59
59
  if (isModuleNotFound) {
60
60
  const info = OPTIONAL_DEPENDENCIES[packageName];
61
61
  const sub = submodule || info?.submodule || 'this feature';
@@ -246,7 +246,7 @@ export class WebRTCClient extends EventEmitter {
246
246
  if (message.to !== this.peerId)
247
247
  return;
248
248
  const pc = this.connections.get(message.from);
249
- if (pc && pc.remoteDescription) {
249
+ if (pc?.remoteDescription) {
250
250
  await pc.addIceCandidate(message.payload);
251
251
  }
252
252
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recker",
3
- "version": "1.0.19",
3
+ "version": "1.0.20-next.963881c",
4
4
  "description": "AI & DevX focused HTTP client for Node.js 18+",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -144,6 +144,7 @@
144
144
  "@types/node": "^24.10.1",
145
145
  "@types/ssh2-sftp-client": "^9.0.5",
146
146
  "@types/superagent": "^8.1.9",
147
+ "@types/ws": "^8.18.1",
147
148
  "@vitest/coverage-v8": "^3.2.4",
148
149
  "axios": "^1.13.2",
149
150
  "cardinal": "^2.1.1",
@@ -164,6 +165,7 @@
164
165
  "tsx": "^4.20.6",
165
166
  "typescript": "^5.9.3",
166
167
  "vitest": "^3.2.4",
168
+ "ws": "^8.18.3",
167
169
  "zod": "^4.1.13"
168
170
  },
169
171
  "scripts": {