@replayio-app-building/netlify-recorder 0.51.0 → 0.53.0
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.ts +2 -0
- package/dist/index.js +45 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,8 @@ interface BlobData {
|
|
|
105
105
|
* network calls).
|
|
106
106
|
*/
|
|
107
107
|
originalRequestId?: string;
|
|
108
|
+
/** The version of @replayio-app-building/netlify-recorder that generated this blob. */
|
|
109
|
+
packageVersion: string;
|
|
108
110
|
}
|
|
109
111
|
interface FinishRequestCallbacks {
|
|
110
112
|
/**
|
package/dist/index.js
CHANGED
|
@@ -206,8 +206,11 @@ function replayHttpRequest(url, _method, calls, consumed, callback, silent) {
|
|
|
206
206
|
fakeRes.statusMessage = "";
|
|
207
207
|
fakeRes.headers = {};
|
|
208
208
|
if (call.responseHeaders) {
|
|
209
|
+
const skipHeaders = /* @__PURE__ */ new Set(["content-encoding", "transfer-encoding"]);
|
|
209
210
|
for (const [k, v] of Object.entries(call.responseHeaders)) {
|
|
210
|
-
|
|
211
|
+
if (!skipHeaders.has(k.toLowerCase())) {
|
|
212
|
+
fakeRes.headers[k.toLowerCase()] = v;
|
|
213
|
+
}
|
|
211
214
|
}
|
|
212
215
|
}
|
|
213
216
|
const fakeReq = new Writable({
|
|
@@ -405,6 +408,26 @@ function installNetworkInterceptor(mode, calls, options) {
|
|
|
405
408
|
break;
|
|
406
409
|
}
|
|
407
410
|
}
|
|
411
|
+
if (matchIdx === -1) {
|
|
412
|
+
for (let i = 0; i < calls.length; i++) {
|
|
413
|
+
if (consumed.has(i)) continue;
|
|
414
|
+
const c = calls[i];
|
|
415
|
+
if (c && c.url === url) {
|
|
416
|
+
matchIdx = i;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (matchIdx === -1 && requestBody) {
|
|
422
|
+
for (let i = 0; i < calls.length; i++) {
|
|
423
|
+
if (consumed.has(i)) continue;
|
|
424
|
+
const c = calls[i];
|
|
425
|
+
if (c && c.requestBody === requestBody) {
|
|
426
|
+
matchIdx = i;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
408
431
|
if (matchIdx === -1) {
|
|
409
432
|
for (let i = 0; i < calls.length; i++) {
|
|
410
433
|
if (!consumed.has(i)) {
|
|
@@ -435,15 +458,22 @@ function installNetworkInterceptor(mode, calls, options) {
|
|
|
435
458
|
}
|
|
436
459
|
const body = call.responseBody ?? "";
|
|
437
460
|
const status = isPending ? 200 : call.responseStatus;
|
|
461
|
+
const skipHeaders = /* @__PURE__ */ new Set(["content-encoding", "transfer-encoding"]);
|
|
462
|
+
const filteredHeaders = {};
|
|
463
|
+
for (const [k, v] of Object.entries(call.responseHeaders ?? {})) {
|
|
464
|
+
if (!skipHeaders.has(k.toLowerCase())) {
|
|
465
|
+
filteredHeaders[k.toLowerCase()] = v;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
438
468
|
return {
|
|
439
469
|
ok: status >= 200 && status < 300,
|
|
440
470
|
status,
|
|
441
471
|
statusText: "",
|
|
442
472
|
headers: {
|
|
443
|
-
get: (name) =>
|
|
444
|
-
has: (name) => name.toLowerCase() in
|
|
473
|
+
get: (name) => filteredHeaders[name.toLowerCase()] ?? null,
|
|
474
|
+
has: (name) => name.toLowerCase() in filteredHeaders,
|
|
445
475
|
forEach: (cb) => {
|
|
446
|
-
for (const [k, v] of Object.entries(
|
|
476
|
+
for (const [k, v] of Object.entries(filteredHeaders)) cb(v, k);
|
|
447
477
|
}
|
|
448
478
|
},
|
|
449
479
|
text: async () => body,
|
|
@@ -938,7 +968,8 @@ async function finishRequest(requestContext, callbacks, response, options) {
|
|
|
938
968
|
statusCode: response.statusCode ?? response.status ?? 0,
|
|
939
969
|
body: typeof response.body === "string" ? response.body : void 0
|
|
940
970
|
},
|
|
941
|
-
originalRequestId: options?.originalRequestId
|
|
971
|
+
originalRequestId: options?.originalRequestId,
|
|
972
|
+
packageVersion: "0.53.0"
|
|
942
973
|
};
|
|
943
974
|
const blobData = redactBlobData(rawBlobData);
|
|
944
975
|
const blobContent = JSON.stringify(blobData);
|
|
@@ -1089,6 +1120,14 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
|
|
|
1089
1120
|
blobData.capturedData.envReads
|
|
1090
1121
|
);
|
|
1091
1122
|
globalThis.__REPLAY_RECORDING_MODE__ = true;
|
|
1123
|
+
const origMathRandom = Math.random;
|
|
1124
|
+
let prngState = 305419896;
|
|
1125
|
+
Math.random = () => {
|
|
1126
|
+
prngState = prngState + 1831565813 | 0;
|
|
1127
|
+
let t = Math.imul(prngState ^ prngState >>> 15, 1 | prngState);
|
|
1128
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
1129
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1130
|
+
};
|
|
1092
1131
|
const g = globalThis;
|
|
1093
1132
|
if (typeof g.Blob === "undefined") {
|
|
1094
1133
|
try {
|
|
@@ -1452,6 +1491,7 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
|
|
|
1452
1491
|
globalThis.__REPLAY_RECORDING_MODE__ = false;
|
|
1453
1492
|
delete g.__REPLAY_REQUEST_COOKIES__;
|
|
1454
1493
|
delete g.__REPLAY_REQUEST_HEADERS__;
|
|
1494
|
+
Math.random = origMathRandom;
|
|
1455
1495
|
networkHandle.restore();
|
|
1456
1496
|
envHandle.restore();
|
|
1457
1497
|
}
|