test-proxy-recorder 0.3.4 → 0.3.6

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { RECORDING_ID_HEADER, createHeadersWithRecordingId, getRecordingId, setNextProxyHeaders } from './nextjs/index.cjs';
2
2
  import http from 'node:http';
3
- export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-BlBWqSE4.cjs';
3
+ export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-BloXCw69.cjs';
4
4
  import '@playwright/test';
5
5
 
6
6
  declare class ProxyServer {
@@ -12,58 +12,26 @@ declare class ProxyServer {
12
12
  private proxy;
13
13
  private currentSession;
14
14
  private recordingsDir;
15
+ private timeoutMs;
15
16
  private recordingIdCounter;
16
17
  private sequenceCounterByKey;
17
18
  private replaySessions;
18
19
  private recordingPromises;
19
20
  private flushPromise;
20
- constructor(target: string, recordingsDir: string);
21
+ constructor(target: string, recordingsDir: string, timeoutMs?: number);
21
22
  init(): Promise<void>;
22
23
  listen(port: number): http.Server;
23
24
  private setupProxyEventHandlers;
24
25
  private handleProxyError;
25
- /**
26
- * Get CORS headers for a given request
27
- * @param req The incoming HTTP request
28
- * @returns An object containing CORS headers
29
- */
30
- private getCorsHeaders;
31
- private addCorsHeaders;
32
- private getTarget;
33
- /**
34
- * Extract recording ID from custom HTTP header
35
- * Used for concurrent replay session routing, especially with Next.js
36
- * @param req The incoming HTTP request
37
- * @returns The recording ID from header, or null if not found
38
- */
39
- private getRecordingIdFromHeader;
40
- /**
41
- * Extract recording ID from request cookie
42
- * Used for concurrent replay session routing (fallback method)
43
- * @param req The incoming HTTP request
44
- * @returns The recording ID from cookie, or null if not found
45
- */
46
- private getRecordingIdFromCookie;
47
- /**
48
- * Extract recording ID from request using custom header (preferred) or cookie (fallback)
49
- * @param req The incoming HTTP request
50
- * @returns The recording ID, or null if not found
51
- */
52
- private getRecordingIdFromRequest;
53
- /**
54
- * Get or create a replay session state for a given recording ID
55
- * @param recordingId The recording ID to get/create session for
56
- * @returns The replay session state
57
- */
58
- private getOrCreateReplaySession;
59
26
  /**
60
27
  * Clean up a session - removes it from memory and resets counters
61
28
  * @param sessionId The session ID to clean up
62
29
  */
63
30
  private cleanupSession;
64
- private parseGetParams;
65
- private parseControlRequest;
31
+ private parseControlBody;
66
32
  private handleControlRequest;
33
+ private handleControlPost;
34
+ private applyModeChange;
67
35
  private clearModeTimeout;
68
36
  private switchMode;
69
37
  private switchToTransparentMode;
@@ -73,17 +41,21 @@ declare class ProxyServer {
73
41
  private flushPendingRecordings;
74
42
  private saveCurrentSession;
75
43
  private getRecordingIdOrError;
76
- private getServedTracker;
77
- private getSortedRecordings;
78
- private selectReplayRecord;
79
44
  private handleReplayRequest;
80
45
  private handleReplayError;
81
46
  private handleRequest;
82
47
  private handleCorsPreflightRequest;
83
48
  private handleProxyRequest;
84
- private recordAndProxyRequest;
49
+ private recordAndProxy;
85
50
  private handleUpgrade;
86
- private handleRecordWebSocket;
51
+ /**
52
+ * Resolve the recording ID for a WebSocket upgrade request.
53
+ * Mirrors getRecordingIdOrError(): prefer the header/cookie from the request,
54
+ * fall back to this.replayId only when there is at most one active session.
55
+ * Browsers cannot set custom headers on WebSocket handshakes from JS, but
56
+ * Playwright's setExtraHTTPHeaders / cookies still reach the upgrade request.
57
+ */
58
+ private getWsRecordingId;
87
59
  private handleReplayWebSocket;
88
60
  private logServerStartup;
89
61
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { RECORDING_ID_HEADER, createHeadersWithRecordingId, getRecordingId, setNextProxyHeaders } from './nextjs/index.js';
2
2
  import http from 'node:http';
3
- export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-BlBWqSE4.js';
3
+ export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-BloXCw69.js';
4
4
  import '@playwright/test';
5
5
 
6
6
  declare class ProxyServer {
@@ -12,58 +12,26 @@ declare class ProxyServer {
12
12
  private proxy;
13
13
  private currentSession;
14
14
  private recordingsDir;
15
+ private timeoutMs;
15
16
  private recordingIdCounter;
16
17
  private sequenceCounterByKey;
17
18
  private replaySessions;
18
19
  private recordingPromises;
19
20
  private flushPromise;
20
- constructor(target: string, recordingsDir: string);
21
+ constructor(target: string, recordingsDir: string, timeoutMs?: number);
21
22
  init(): Promise<void>;
22
23
  listen(port: number): http.Server;
23
24
  private setupProxyEventHandlers;
24
25
  private handleProxyError;
25
- /**
26
- * Get CORS headers for a given request
27
- * @param req The incoming HTTP request
28
- * @returns An object containing CORS headers
29
- */
30
- private getCorsHeaders;
31
- private addCorsHeaders;
32
- private getTarget;
33
- /**
34
- * Extract recording ID from custom HTTP header
35
- * Used for concurrent replay session routing, especially with Next.js
36
- * @param req The incoming HTTP request
37
- * @returns The recording ID from header, or null if not found
38
- */
39
- private getRecordingIdFromHeader;
40
- /**
41
- * Extract recording ID from request cookie
42
- * Used for concurrent replay session routing (fallback method)
43
- * @param req The incoming HTTP request
44
- * @returns The recording ID from cookie, or null if not found
45
- */
46
- private getRecordingIdFromCookie;
47
- /**
48
- * Extract recording ID from request using custom header (preferred) or cookie (fallback)
49
- * @param req The incoming HTTP request
50
- * @returns The recording ID, or null if not found
51
- */
52
- private getRecordingIdFromRequest;
53
- /**
54
- * Get or create a replay session state for a given recording ID
55
- * @param recordingId The recording ID to get/create session for
56
- * @returns The replay session state
57
- */
58
- private getOrCreateReplaySession;
59
26
  /**
60
27
  * Clean up a session - removes it from memory and resets counters
61
28
  * @param sessionId The session ID to clean up
62
29
  */
63
30
  private cleanupSession;
64
- private parseGetParams;
65
- private parseControlRequest;
31
+ private parseControlBody;
66
32
  private handleControlRequest;
33
+ private handleControlPost;
34
+ private applyModeChange;
67
35
  private clearModeTimeout;
68
36
  private switchMode;
69
37
  private switchToTransparentMode;
@@ -73,17 +41,21 @@ declare class ProxyServer {
73
41
  private flushPendingRecordings;
74
42
  private saveCurrentSession;
75
43
  private getRecordingIdOrError;
76
- private getServedTracker;
77
- private getSortedRecordings;
78
- private selectReplayRecord;
79
44
  private handleReplayRequest;
80
45
  private handleReplayError;
81
46
  private handleRequest;
82
47
  private handleCorsPreflightRequest;
83
48
  private handleProxyRequest;
84
- private recordAndProxyRequest;
49
+ private recordAndProxy;
85
50
  private handleUpgrade;
86
- private handleRecordWebSocket;
51
+ /**
52
+ * Resolve the recording ID for a WebSocket upgrade request.
53
+ * Mirrors getRecordingIdOrError(): prefer the header/cookie from the request,
54
+ * fall back to this.replayId only when there is at most one active session.
55
+ * Browsers cannot set custom headers on WebSocket handshakes from JS, but
56
+ * Playwright's setExtraHTTPHeaders / cookies still reach the upgrade request.
57
+ */
58
+ private getWsRecordingId;
87
59
  private handleReplayWebSocket;
88
60
  private logServerStartup;
89
61
  }