test-proxy-recorder 0.3.5 → 0.3.8

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 {
@@ -16,7 +16,6 @@ declare class ProxyServer {
16
16
  private recordingIdCounter;
17
17
  private sequenceCounterByKey;
18
18
  private replaySessions;
19
- private sessionEvictionTimer;
20
19
  private recordingPromises;
21
20
  private flushPromise;
22
21
  constructor(target: string, recordingsDir: string, timeoutMs?: number);
@@ -24,46 +23,11 @@ declare class ProxyServer {
24
23
  listen(port: number): http.Server;
25
24
  private setupProxyEventHandlers;
26
25
  private handleProxyError;
27
- /**
28
- * Get CORS headers for a given request
29
- * @param req The incoming HTTP request
30
- * @returns An object containing CORS headers
31
- */
32
- private getCorsHeaders;
33
- private addCorsHeaders;
34
- /**
35
- * Extract recording ID from custom HTTP header
36
- * Used for concurrent replay session routing, especially with Next.js
37
- * @param req The incoming HTTP request
38
- * @returns The recording ID from header, or null if not found
39
- */
40
- private getRecordingIdFromHeader;
41
- /**
42
- * Extract recording ID from request cookie
43
- * Used for concurrent replay session routing (fallback method)
44
- * @param req The incoming HTTP request
45
- * @returns The recording ID from cookie, or null if not found
46
- */
47
- private getRecordingIdFromCookie;
48
- /**
49
- * Extract recording ID from request using custom header (preferred) or cookie (fallback)
50
- * @param req The incoming HTTP request
51
- * @returns The recording ID, or null if not found
52
- */
53
- private getRecordingIdFromRequest;
54
- /**
55
- * Get or create a replay session state for a given recording ID
56
- * @param recordingId The recording ID to get/create session for
57
- * @returns The replay session state
58
- */
59
- private getOrCreateReplaySession;
60
26
  /**
61
27
  * Clean up a session - removes it from memory and resets counters
62
28
  * @param sessionId The session ID to clean up
63
29
  */
64
30
  private cleanupSession;
65
- private startSessionEvictionTimer;
66
- private stopSessionEvictionTimer;
67
31
  private parseControlBody;
68
32
  private handleControlRequest;
69
33
  private handleControlPost;
@@ -77,17 +41,21 @@ declare class ProxyServer {
77
41
  private flushPendingRecordings;
78
42
  private saveCurrentSession;
79
43
  private getRecordingIdOrError;
80
- private getServedTracker;
81
- private getSortedRecordings;
82
- private selectReplayRecord;
83
44
  private handleReplayRequest;
84
45
  private handleReplayError;
85
46
  private handleRequest;
86
47
  private handleCorsPreflightRequest;
87
48
  private handleProxyRequest;
88
- private recordAndProxyRequest;
49
+ private recordAndProxy;
89
50
  private handleUpgrade;
90
- 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;
91
59
  private handleReplayWebSocket;
92
60
  private logServerStartup;
93
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 {
@@ -16,7 +16,6 @@ declare class ProxyServer {
16
16
  private recordingIdCounter;
17
17
  private sequenceCounterByKey;
18
18
  private replaySessions;
19
- private sessionEvictionTimer;
20
19
  private recordingPromises;
21
20
  private flushPromise;
22
21
  constructor(target: string, recordingsDir: string, timeoutMs?: number);
@@ -24,46 +23,11 @@ declare class ProxyServer {
24
23
  listen(port: number): http.Server;
25
24
  private setupProxyEventHandlers;
26
25
  private handleProxyError;
27
- /**
28
- * Get CORS headers for a given request
29
- * @param req The incoming HTTP request
30
- * @returns An object containing CORS headers
31
- */
32
- private getCorsHeaders;
33
- private addCorsHeaders;
34
- /**
35
- * Extract recording ID from custom HTTP header
36
- * Used for concurrent replay session routing, especially with Next.js
37
- * @param req The incoming HTTP request
38
- * @returns The recording ID from header, or null if not found
39
- */
40
- private getRecordingIdFromHeader;
41
- /**
42
- * Extract recording ID from request cookie
43
- * Used for concurrent replay session routing (fallback method)
44
- * @param req The incoming HTTP request
45
- * @returns The recording ID from cookie, or null if not found
46
- */
47
- private getRecordingIdFromCookie;
48
- /**
49
- * Extract recording ID from request using custom header (preferred) or cookie (fallback)
50
- * @param req The incoming HTTP request
51
- * @returns The recording ID, or null if not found
52
- */
53
- private getRecordingIdFromRequest;
54
- /**
55
- * Get or create a replay session state for a given recording ID
56
- * @param recordingId The recording ID to get/create session for
57
- * @returns The replay session state
58
- */
59
- private getOrCreateReplaySession;
60
26
  /**
61
27
  * Clean up a session - removes it from memory and resets counters
62
28
  * @param sessionId The session ID to clean up
63
29
  */
64
30
  private cleanupSession;
65
- private startSessionEvictionTimer;
66
- private stopSessionEvictionTimer;
67
31
  private parseControlBody;
68
32
  private handleControlRequest;
69
33
  private handleControlPost;
@@ -77,17 +41,21 @@ declare class ProxyServer {
77
41
  private flushPendingRecordings;
78
42
  private saveCurrentSession;
79
43
  private getRecordingIdOrError;
80
- private getServedTracker;
81
- private getSortedRecordings;
82
- private selectReplayRecord;
83
44
  private handleReplayRequest;
84
45
  private handleReplayError;
85
46
  private handleRequest;
86
47
  private handleCorsPreflightRequest;
87
48
  private handleProxyRequest;
88
- private recordAndProxyRequest;
49
+ private recordAndProxy;
89
50
  private handleUpgrade;
90
- 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;
91
59
  private handleReplayWebSocket;
92
60
  private logServerStartup;
93
61
  }