test-proxy-recorder 0.1.0 → 0.1.1
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/dist/index.cjs +597 -0
- package/dist/index.d.cts +88 -0
- package/dist/index.d.ts +88 -5
- package/dist/index.mjs +582 -0
- package/dist/playwright/index.cjs +72 -0
- package/dist/playwright/index.d.cts +50 -0
- package/dist/playwright/index.d.ts +12 -10
- package/dist/playwright/index.mjs +65 -0
- package/dist/proxy.js +555 -4
- package/package.json +11 -5
- package/dist/ProxyServer.d.ts +0 -39
- package/dist/ProxyServer.d.ts.map +0 -1
- package/dist/ProxyServer.js +0 -464
- package/dist/cli.d.ts +0 -8
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -32
- package/dist/constants.d.ts +0 -7
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/playwright/index.d.ts.map +0 -1
- package/dist/playwright/index.js +0 -92
- package/dist/proxy.d.ts +0 -2
- package/dist/proxy.d.ts.map +0 -1
- package/dist/types.d.ts +0 -46
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/utils/fileUtils.d.ts +0 -5
- package/dist/utils/fileUtils.d.ts.map +0 -1
- package/dist/utils/fileUtils.js +0 -16
- package/dist/utils/httpHelpers.d.ts +0 -4
- package/dist/utils/httpHelpers.d.ts.map +0 -1
- package/dist/utils/httpHelpers.js +0 -13
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -4
- package/dist/utils/requestKeyGenerator.d.ts +0 -3
- package/dist/utils/requestKeyGenerator.d.ts.map +0 -1
- package/dist/utils/requestKeyGenerator.js +0 -24
package/dist/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import http from 'node:http';
|
|
2
|
-
export declare const Modes: {
|
|
3
|
-
readonly transparent: "transparent";
|
|
4
|
-
readonly record: "record";
|
|
5
|
-
readonly replay: "replay";
|
|
6
|
-
};
|
|
7
|
-
export type Mode = (typeof Modes)[keyof typeof Modes];
|
|
8
|
-
export interface ControlRequest {
|
|
9
|
-
mode: Mode;
|
|
10
|
-
id?: string;
|
|
11
|
-
timeout?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface RecordedRequest {
|
|
14
|
-
method: string;
|
|
15
|
-
url: string;
|
|
16
|
-
headers: http.IncomingHttpHeaders;
|
|
17
|
-
body: string | null;
|
|
18
|
-
}
|
|
19
|
-
export interface RecordedResponse {
|
|
20
|
-
statusCode: number;
|
|
21
|
-
headers: http.IncomingHttpHeaders;
|
|
22
|
-
body: string | null;
|
|
23
|
-
}
|
|
24
|
-
export interface Recording {
|
|
25
|
-
request: RecordedRequest;
|
|
26
|
-
response?: RecordedResponse;
|
|
27
|
-
timestamp: string;
|
|
28
|
-
key: string;
|
|
29
|
-
}
|
|
30
|
-
export interface WebSocketMessage {
|
|
31
|
-
direction: 'client-to-server' | 'server-to-client';
|
|
32
|
-
data: string;
|
|
33
|
-
timestamp: string;
|
|
34
|
-
}
|
|
35
|
-
export interface WebSocketRecording {
|
|
36
|
-
url: string;
|
|
37
|
-
messages: WebSocketMessage[];
|
|
38
|
-
timestamp: string;
|
|
39
|
-
key: string;
|
|
40
|
-
}
|
|
41
|
-
export interface RecordingSession {
|
|
42
|
-
id: string;
|
|
43
|
-
recordings: Recording[];
|
|
44
|
-
websocketRecordings: WebSocketRecording[];
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,eAAO,MAAM,KAAK;;;;CAIR,CAAC;AAEX,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC;IAClC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC;IAClC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,kBAAkB,GAAG,kBAAkB,CAAC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;CAC3C"}
|
package/dist/types.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { RecordingSession } from '../types.js';
|
|
2
|
-
export declare function getRecordingPath(recordingsDir: string, id: string): string;
|
|
3
|
-
export declare function loadRecordingSession(filePath: string): Promise<RecordingSession>;
|
|
4
|
-
export declare function saveRecordingSession(recordingsDir: string, session: RecordingSession): Promise<void>;
|
|
5
|
-
//# sourceMappingURL=fileUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileUtils.d.ts","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,gBAAgB,CAAC,CAG3B;AAED,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CASf"}
|
package/dist/utils/fileUtils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
const JSON_INDENT_SPACES = 2;
|
|
4
|
-
export function getRecordingPath(recordingsDir, id) {
|
|
5
|
-
return path.join(recordingsDir, `${id}.json`);
|
|
6
|
-
}
|
|
7
|
-
export async function loadRecordingSession(filePath) {
|
|
8
|
-
const fileContent = await fs.readFile(filePath, 'utf8');
|
|
9
|
-
return JSON.parse(fileContent);
|
|
10
|
-
}
|
|
11
|
-
export async function saveRecordingSession(recordingsDir, session) {
|
|
12
|
-
const filePath = getRecordingPath(recordingsDir, session.id);
|
|
13
|
-
await fs.writeFile(filePath, JSON.stringify(session, null, JSON_INDENT_SPACES));
|
|
14
|
-
console.log(`Saved ${session.recordings.length} HTTP recordings and ${session.websocketRecordings?.length || 0} WebSocket recordings to ${filePath}`);
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=fileUtils.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import http from 'node:http';
|
|
2
|
-
export declare function readRequestBody(req: http.IncomingMessage): Promise<string>;
|
|
3
|
-
export declare function sendJsonResponse(res: http.ServerResponse, statusCode: number, data: Record<string, unknown>): void;
|
|
4
|
-
//# sourceMappingURL=httpHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/httpHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,wBAAsB,eAAe,CACnC,GAAG,EAAE,IAAI,CAAC,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC,CAMjB;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,IAAI,CAGN"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const CONTENT_TYPE_JSON = 'application/json';
|
|
2
|
-
export async function readRequestBody(req) {
|
|
3
|
-
let body = '';
|
|
4
|
-
for await (const chunk of req) {
|
|
5
|
-
body += chunk.toString();
|
|
6
|
-
}
|
|
7
|
-
return body;
|
|
8
|
-
}
|
|
9
|
-
export function sendJsonResponse(res, statusCode, data) {
|
|
10
|
-
res.writeHead(statusCode, { 'Content-Type': CONTENT_TYPE_JSON });
|
|
11
|
-
res.end(JSON.stringify(data));
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=httpHelpers.js.map
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC"}
|
package/dist/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestKeyGenerator.d.ts","sourceRoot":"","sources":["../../src/utils/requestKeyGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,GAAG,MAAM,CASpE"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const QUERY_HASH_LENGTH = 8;
|
|
2
|
-
export function generateRequestKey(req) {
|
|
3
|
-
const urlParts = req.url.split('?');
|
|
4
|
-
const pathname = urlParts[0];
|
|
5
|
-
const query = urlParts[1] || '';
|
|
6
|
-
const normalizedPath = normalizePathname(pathname);
|
|
7
|
-
const queryHash = generateQueryHash(query);
|
|
8
|
-
return `${req.method}_${normalizedPath}${queryHash}.json`;
|
|
9
|
-
}
|
|
10
|
-
function normalizePathname(pathname) {
|
|
11
|
-
const normalized = pathname.replaceAll('/', '_').replace(/^_/, '');
|
|
12
|
-
return normalized || 'root';
|
|
13
|
-
}
|
|
14
|
-
function generateQueryHash(query) {
|
|
15
|
-
if (!query) {
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
const hash = Buffer.from(query)
|
|
19
|
-
.toString('base64')
|
|
20
|
-
.replaceAll(/[^a-zA-Z0-9]/g, '')
|
|
21
|
-
.slice(0, Math.max(0, QUERY_HASH_LENGTH));
|
|
22
|
-
return `_${hash}`;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=requestKeyGenerator.js.map
|