@sailfish-ai/recorder 1.2.7 → 1.2.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.js +25 -9
- package/dist/sailfish-recorder.cjs.js +1 -1
- package/dist/sailfish-recorder.cjs.js.br +0 -0
- package/dist/sailfish-recorder.cjs.js.gz +0 -0
- package/dist/sailfish-recorder.es.js +1 -1
- package/dist/sailfish-recorder.es.js.br +0 -0
- package/dist/sailfish-recorder.es.js.gz +0 -0
- package/dist/sailfish-recorder.umd.js +1 -1
- package/dist/sailfish-recorder.umd.js.br +0 -0
- package/dist/sailfish-recorder.umd.js.gz +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -157,7 +157,7 @@ export function matchUrlWithWildcard(url, patterns) {
|
|
|
157
157
|
return true;
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
// Updated XMLHttpRequest interceptor with
|
|
160
|
+
// Updated XMLHttpRequest interceptor with CORS protection
|
|
161
161
|
function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsToPropagateHeadersTo = []) {
|
|
162
162
|
const originalOpen = XMLHttpRequest.prototype.open;
|
|
163
163
|
const originalSend = XMLHttpRequest.prototype.send;
|
|
@@ -167,31 +167,47 @@ function setupXMLHttpRequestInterceptor(domainsToNotPropagateHeaderTo, domainsTo
|
|
|
167
167
|
...DOMAINS_TO_NOT_PROPAGATE_HEADER_TO_DEFAULT,
|
|
168
168
|
...domainsToNotPropagateHeaderTo,
|
|
169
169
|
];
|
|
170
|
-
//
|
|
170
|
+
// Exclude certain resource types (like images) from being intercepted
|
|
171
|
+
const resourceExcludeList = ["image", "font", "script"];
|
|
172
|
+
// Intercept open()
|
|
171
173
|
XMLHttpRequest.prototype.open = function (method, url, ...args) {
|
|
172
|
-
console.log("Sailfish XMLHttpRequest.prototype.open");
|
|
174
|
+
console.log("Sailfish XMLHttpRequest.prototype.open", method, url);
|
|
173
175
|
this._requestUrl = typeof url === "string" && url.length > 0 ? url : null;
|
|
176
|
+
// Skip interception for excluded resource types (e.g., images)
|
|
177
|
+
const resourceType = this.getResponseHeader("content-type");
|
|
178
|
+
if (resourceType &&
|
|
179
|
+
resourceExcludeList.some((type) => resourceType.includes(type))) {
|
|
180
|
+
console.log(`[XML] Skipping resource request for ${url} (type: ${resourceType})`);
|
|
181
|
+
return originalOpen.apply(this, [method, url, ...args]);
|
|
182
|
+
}
|
|
174
183
|
return originalOpen.apply(this, [method, url, ...args]);
|
|
175
184
|
};
|
|
176
185
|
// Intercept send()
|
|
177
186
|
XMLHttpRequest.prototype.send = function (...args) {
|
|
178
|
-
console.log("Sailfish XMLHttpRequest.prototype.send");
|
|
187
|
+
console.log("Sailfish XMLHttpRequest.prototype.send", this._requestUrl);
|
|
179
188
|
const url = this._requestUrl;
|
|
180
189
|
if (!url)
|
|
181
190
|
return originalSend.apply(this, args);
|
|
182
|
-
//
|
|
191
|
+
// Skip domain check for certain resources like images or fonts
|
|
183
192
|
if (matchUrlWithWildcard(url, combinedIgnoreDomains)) {
|
|
184
|
-
console.log(
|
|
193
|
+
console.log(`[XML] [InIgnoreDomains] IGNORE --> ${url}`);
|
|
185
194
|
return originalSend.apply(this, args);
|
|
186
195
|
}
|
|
187
196
|
// Check if domain should propagate headers
|
|
188
197
|
const shouldPropagateHeader = domainsToPropagateHeadersTo.length === 0 ||
|
|
189
198
|
matchUrlWithWildcard(url, domainsToPropagateHeadersTo);
|
|
190
199
|
if (sessionId && shouldPropagateHeader) {
|
|
191
|
-
console.log(
|
|
192
|
-
|
|
200
|
+
console.log(`[XML] [InPropagateDomains] PROPAGATE FOR --> ${url}`);
|
|
201
|
+
try {
|
|
202
|
+
this.setRequestHeader("X-Sf3-Rid", sessionId);
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
console.warn(`Could not set X-Sf3-Rid header for ${url}`, e);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
console.log(`[XML] [NOT InPropagateDomains] IGNORE --> ${url}`);
|
|
193
210
|
}
|
|
194
|
-
console.log([`[XML] [NOT InPropagateDomans] IGNORE --> ${url}`]);
|
|
195
211
|
return originalSend.apply(this, args);
|
|
196
212
|
};
|
|
197
213
|
}
|