@sgedda/mockifyer-fetch 1.8.34 → 1.8.36
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.
|
@@ -9,6 +9,7 @@ export declare class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<an
|
|
|
9
9
|
private proxyRecordResponses;
|
|
10
10
|
private getClientId?;
|
|
11
11
|
private getStrictLaneScenario?;
|
|
12
|
+
private getUpstreamTlsInsecure?;
|
|
12
13
|
private getExplicitProxyScenarioContext?;
|
|
13
14
|
private clientIdSnapshot?;
|
|
14
15
|
private deviceId?;
|
|
@@ -26,6 +27,7 @@ export declare class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<an
|
|
|
26
27
|
clientId?: string;
|
|
27
28
|
getClientId?: () => string | undefined;
|
|
28
29
|
getStrictLaneScenario?: () => boolean;
|
|
30
|
+
getUpstreamTlsInsecure?: () => boolean;
|
|
29
31
|
/** When false, skip `/api/proxy` and call the real URL (devtools-friendly passthrough). */
|
|
30
32
|
getExplicitProxyScenarioContext?: () => boolean;
|
|
31
33
|
deviceId?: string;
|
|
@@ -14,6 +14,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
|
|
|
14
14
|
this.proxyRecordResponses = config?.proxy?.recordResponses ?? false;
|
|
15
15
|
this.getClientId = config?.getClientId;
|
|
16
16
|
this.getStrictLaneScenario = config?.getStrictLaneScenario;
|
|
17
|
+
this.getUpstreamTlsInsecure = config?.getUpstreamTlsInsecure;
|
|
17
18
|
this.getExplicitProxyScenarioContext = config?.getExplicitProxyScenarioContext;
|
|
18
19
|
this.clientIdSnapshot = config?.clientId;
|
|
19
20
|
this.deviceId = config?.deviceId;
|
|
@@ -101,6 +102,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
|
|
|
101
102
|
recordOnMiss: this.proxyRecordOnMiss,
|
|
102
103
|
recordResponses: this.proxyRecordResponses,
|
|
103
104
|
strictLaneScenario: this.getStrictLaneScenario?.() ?? true,
|
|
105
|
+
upstreamTlsInsecure: this.getUpstreamTlsInsecure?.() ?? false,
|
|
104
106
|
config,
|
|
105
107
|
fetchFn,
|
|
106
108
|
logTag: 'Mockifyer-Fetch',
|
package/dist/index.js
CHANGED
|
@@ -182,6 +182,7 @@ class MockifyerClass {
|
|
|
182
182
|
clientId: this.config.clientId,
|
|
183
183
|
getClientId: () => this.config.clientId,
|
|
184
184
|
getStrictLaneScenario: () => (0, mockifyer_core_1.resolveProxyStrictLaneScenario)(this.config),
|
|
185
|
+
getUpstreamTlsInsecure: () => (0, mockifyer_core_1.resolveProxyUpstreamTlsInsecure)(this.config),
|
|
185
186
|
getExplicitProxyScenarioContext: () => (0, mockifyer_core_1.isExplicitProxyScenarioContext)(this.config),
|
|
186
187
|
deviceId: this.config.deviceId,
|
|
187
188
|
});
|
|
@@ -409,6 +410,10 @@ class MockifyerClass {
|
|
|
409
410
|
config.__mockifyer_bypass = true;
|
|
410
411
|
return config;
|
|
411
412
|
}
|
|
413
|
+
if ((0, mockifyer_core_1.shouldBypassMockifyerForUrl)(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
414
|
+
config.__mockifyer_bypass = true;
|
|
415
|
+
return config;
|
|
416
|
+
}
|
|
412
417
|
if (!(0, mockifyer_core_1.shouldApplyMockifyer)(this.activationMode, config.headers, {
|
|
413
418
|
useProxyLane: { proxyBaseUrl: this.config.proxy?.baseUrl, resolvedClientId: this.config.clientId },
|
|
414
419
|
})) {
|
|
@@ -742,10 +747,10 @@ class MockifyerClass {
|
|
|
742
747
|
return;
|
|
743
748
|
}
|
|
744
749
|
const url = response.config?.url || response.request?.responseURL || response.url || '';
|
|
745
|
-
|
|
746
|
-
if (url && (0, mockifyer_core_1.shouldExcludeUrl)(url, this.config.excludedUrls)) {
|
|
750
|
+
if (url && (0, mockifyer_core_1.shouldBypassMockifyerForUrl)(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
747
751
|
return;
|
|
748
752
|
}
|
|
753
|
+
const recordingExclusions = (0, mockifyer_core_1.resolveRecordingExclusions)(this.config);
|
|
749
754
|
if (url &&
|
|
750
755
|
(0, mockifyer_core_1.shouldExcludeRecording)(url, recordingExclusions, this.config.baseUrl)) {
|
|
751
756
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sgedda/mockifyer-fetch",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.36",
|
|
4
4
|
"description": "Mockifyer for Fetch - API mocking and logging utility for storing and replaying API responses",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@sgedda/mockifyer-core": "^1.10.
|
|
52
|
+
"@sgedda/mockifyer-core": "^1.10.10"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^20.11.24",
|
|
@@ -21,6 +21,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
21
21
|
private proxyRecordResponses: boolean;
|
|
22
22
|
private getClientId?: () => string | undefined;
|
|
23
23
|
private getStrictLaneScenario?: () => boolean;
|
|
24
|
+
private getUpstreamTlsInsecure?: () => boolean;
|
|
24
25
|
private getExplicitProxyScenarioContext?: () => boolean;
|
|
25
26
|
private clientIdSnapshot?: string;
|
|
26
27
|
private deviceId?: string;
|
|
@@ -39,6 +40,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
39
40
|
clientId?: string;
|
|
40
41
|
getClientId?: () => string | undefined;
|
|
41
42
|
getStrictLaneScenario?: () => boolean;
|
|
43
|
+
getUpstreamTlsInsecure?: () => boolean;
|
|
42
44
|
/** When false, skip `/api/proxy` and call the real URL (devtools-friendly passthrough). */
|
|
43
45
|
getExplicitProxyScenarioContext?: () => boolean;
|
|
44
46
|
deviceId?: string;
|
|
@@ -52,6 +54,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
52
54
|
this.proxyRecordResponses = config?.proxy?.recordResponses ?? false;
|
|
53
55
|
this.getClientId = config?.getClientId;
|
|
54
56
|
this.getStrictLaneScenario = config?.getStrictLaneScenario;
|
|
57
|
+
this.getUpstreamTlsInsecure = config?.getUpstreamTlsInsecure;
|
|
55
58
|
this.getExplicitProxyScenarioContext = config?.getExplicitProxyScenarioContext;
|
|
56
59
|
this.clientIdSnapshot = config?.clientId;
|
|
57
60
|
this.deviceId = config?.deviceId;
|
|
@@ -149,6 +152,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
149
152
|
recordOnMiss: this.proxyRecordOnMiss,
|
|
150
153
|
recordResponses: this.proxyRecordResponses,
|
|
151
154
|
strictLaneScenario: this.getStrictLaneScenario?.() ?? true,
|
|
155
|
+
upstreamTlsInsecure: this.getUpstreamTlsInsecure?.() ?? false,
|
|
152
156
|
config,
|
|
153
157
|
fetchFn,
|
|
154
158
|
logTag: 'Mockifyer-Fetch',
|
package/src/index.ts
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
checkRequestLimit,
|
|
36
36
|
prepareMockResponseBody,
|
|
37
37
|
getCurrentDate,
|
|
38
|
-
|
|
38
|
+
shouldBypassMockifyerForUrl,
|
|
39
39
|
resolveRecordingExclusions,
|
|
40
40
|
shouldExcludeRecording,
|
|
41
41
|
mockPassesThroughToRealApi,
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
resolveClientId,
|
|
50
50
|
resolveExplicitClientIdOnly,
|
|
51
51
|
resolveProxyStrictLaneScenario,
|
|
52
|
+
resolveProxyUpstreamTlsInsecure,
|
|
52
53
|
registerMockifyerInstance,
|
|
53
54
|
logMockifyerInitSummary,
|
|
54
55
|
tryGetClientIdFromLaunchArguments,
|
|
@@ -253,6 +254,7 @@ class MockifyerClass {
|
|
|
253
254
|
clientId: this.config.clientId,
|
|
254
255
|
getClientId: () => this.config.clientId,
|
|
255
256
|
getStrictLaneScenario: () => resolveProxyStrictLaneScenario(this.config),
|
|
257
|
+
getUpstreamTlsInsecure: () => resolveProxyUpstreamTlsInsecure(this.config),
|
|
256
258
|
getExplicitProxyScenarioContext: () => isExplicitProxyScenarioContext(this.config),
|
|
257
259
|
deviceId: (this.config as any).deviceId,
|
|
258
260
|
});
|
|
@@ -529,6 +531,11 @@ class MockifyerClass {
|
|
|
529
531
|
return config;
|
|
530
532
|
}
|
|
531
533
|
|
|
534
|
+
if (shouldBypassMockifyerForUrl(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
535
|
+
(config as any).__mockifyer_bypass = true;
|
|
536
|
+
return config;
|
|
537
|
+
}
|
|
538
|
+
|
|
532
539
|
if (
|
|
533
540
|
!shouldApplyMockifyer(this.activationMode, config.headers, {
|
|
534
541
|
useProxyLane: { proxyBaseUrl: this.config.proxy?.baseUrl, resolvedClientId: this.config.clientId },
|
|
@@ -940,10 +947,10 @@ class MockifyerClass {
|
|
|
940
947
|
}
|
|
941
948
|
|
|
942
949
|
const url = response.config?.url || (response as any).request?.responseURL || (response as any).url || '';
|
|
943
|
-
|
|
944
|
-
if (url && shouldExcludeUrl(url, this.config.excludedUrls)) {
|
|
950
|
+
if (url && shouldBypassMockifyerForUrl(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
945
951
|
return;
|
|
946
952
|
}
|
|
953
|
+
const recordingExclusions = resolveRecordingExclusions(this.config);
|
|
947
954
|
if (
|
|
948
955
|
url &&
|
|
949
956
|
shouldExcludeRecording(url, recordingExclusions, this.config.baseUrl)
|