@replayio-app-building/netlify-recorder 0.57.0 → 0.58.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.
Files changed (2) hide show
  1. package/dist/index.js +37 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -984,7 +984,7 @@ async function finishRequest(requestContext, callbacks, response, options) {
984
984
  body: typeof response.body === "string" ? response.body : void 0
985
985
  },
986
986
  originalRequestId: options?.originalRequestId,
987
- packageVersion: "0.57.0"
987
+ packageVersion: "0.58.0"
988
988
  };
989
989
  const blobData = redactBlobData(rawBlobData);
990
990
  const blobContent = JSON.stringify(blobData);
@@ -1175,16 +1175,16 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1175
1175
  return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
1176
1176
  };
1177
1177
  }
1178
- const g = globalThis;
1179
- if (typeof g.Blob === "undefined") {
1178
+ const g2 = globalThis;
1179
+ if (typeof g2.Blob === "undefined") {
1180
1180
  try {
1181
1181
  const { Blob: Blob2 } = __require("buffer");
1182
- g.Blob = Blob2;
1182
+ g2.Blob = Blob2;
1183
1183
  } catch {
1184
1184
  }
1185
1185
  }
1186
- if (typeof g.File === "undefined") {
1187
- const B = g.Blob ?? Object;
1186
+ if (typeof g2.File === "undefined") {
1187
+ const B = g2.Blob ?? Object;
1188
1188
  const FileShim = class File {
1189
1189
  name;
1190
1190
  lastModified;
@@ -1194,12 +1194,12 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1194
1194
  this.lastModified = Date.now();
1195
1195
  }
1196
1196
  };
1197
- g.File = FileShim;
1197
+ g2.File = FileShim;
1198
1198
  }
1199
- if (typeof g.crypto === "undefined") {
1199
+ if (typeof g2.crypto === "undefined") {
1200
1200
  try {
1201
1201
  const nodeCrypto = __require("crypto");
1202
- g.crypto = {
1202
+ g2.crypto = {
1203
1203
  randomUUID: () => nodeCrypto.randomUUID(),
1204
1204
  getRandomValues: (buf) => nodeCrypto.getRandomValues(buf),
1205
1205
  subtle: nodeCrypto.webcrypto?.subtle
@@ -1207,16 +1207,16 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1207
1207
  } catch {
1208
1208
  }
1209
1209
  }
1210
- if (g.crypto && typeof g.crypto.subtle === "undefined") {
1210
+ if (g2.crypto && typeof g2.crypto.subtle === "undefined") {
1211
1211
  try {
1212
1212
  const nodeCrypto = __require("crypto");
1213
1213
  if (nodeCrypto.webcrypto?.subtle) {
1214
- g.crypto.subtle = nodeCrypto.webcrypto.subtle;
1214
+ g2.crypto.subtle = nodeCrypto.webcrypto.subtle;
1215
1215
  }
1216
1216
  } catch {
1217
1217
  }
1218
1218
  }
1219
- if (typeof g.Headers === "undefined") {
1219
+ if (typeof g2.Headers === "undefined") {
1220
1220
  const HeadersShim = class Headers {
1221
1221
  _map;
1222
1222
  constructor(init) {
@@ -1254,10 +1254,10 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1254
1254
  return this._map.entries();
1255
1255
  }
1256
1256
  };
1257
- g.Headers = HeadersShim;
1257
+ g2.Headers = HeadersShim;
1258
1258
  }
1259
- if (typeof g.Request === "undefined") {
1260
- const H = g.Headers;
1259
+ if (typeof g2.Request === "undefined") {
1260
+ const H = g2.Headers;
1261
1261
  const RequestShim = class Request {
1262
1262
  method;
1263
1263
  url;
@@ -1283,10 +1283,10 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1283
1283
  });
1284
1284
  }
1285
1285
  };
1286
- g.Request = RequestShim;
1286
+ g2.Request = RequestShim;
1287
1287
  }
1288
- if (typeof g.Response === "undefined") {
1289
- const H = g.Headers;
1288
+ if (typeof g2.Response === "undefined") {
1289
+ const H = g2.Headers;
1290
1290
  const ResponseShim = class Response {
1291
1291
  status;
1292
1292
  statusText;
@@ -1323,7 +1323,7 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1323
1323
  });
1324
1324
  }
1325
1325
  };
1326
- g.Response = ResponseShim;
1326
+ g2.Response = ResponseShim;
1327
1327
  }
1328
1328
  const result = { responseMismatch: false, unconsumedNetworkCalls: false };
1329
1329
  const handlerModule = await import(handlerPath);
@@ -1389,12 +1389,12 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1389
1389
  if (pb.requestInfo.body && pb.requestInfo.method !== "GET" && pb.requestInfo.method !== "HEAD") {
1390
1390
  reqInit.body = pb.requestInfo.body;
1391
1391
  }
1392
- const RequestCtor = g.Request;
1392
+ const RequestCtor = g2.Request;
1393
1393
  if (RequestCtor) {
1394
1394
  const req = new RequestCtor(url, reqInit);
1395
1395
  const ctx = { geo: {}, ip: "127.0.0.1", requestId: "replay-warmup", server: { region: "local" } };
1396
- g.__REPLAY_REQUEST_COOKIES__ = Object.keys(pb.requestInfo.headers).find((k) => k.toLowerCase() === "cookie") ? pb.requestInfo.headers[Object.keys(pb.requestInfo.headers).find((k) => k.toLowerCase() === "cookie")] : "";
1397
- g.__REPLAY_REQUEST_HEADERS__ = pb.requestInfo.headers;
1396
+ g2.__REPLAY_REQUEST_COOKIES__ = Object.keys(pb.requestInfo.headers).find((k) => k.toLowerCase() === "cookie") ? pb.requestInfo.headers[Object.keys(pb.requestInfo.headers).find((k) => k.toLowerCase() === "cookie")] : "";
1397
+ g2.__REPLAY_REQUEST_HEADERS__ = pb.requestInfo.headers;
1398
1398
  await handler(req, ctx);
1399
1399
  }
1400
1400
  } else {
@@ -1445,8 +1445,8 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1445
1445
  }
1446
1446
  const req = new RequestCtor(url, reqInit);
1447
1447
  const cookieKey = Object.keys(requestInfo.headers).find((k) => k.toLowerCase() === "cookie");
1448
- g.__REPLAY_REQUEST_COOKIES__ = cookieKey ? requestInfo.headers[cookieKey] : "";
1449
- g.__REPLAY_REQUEST_HEADERS__ = requestInfo.headers;
1448
+ g2.__REPLAY_REQUEST_COOKIES__ = cookieKey ? requestInfo.headers[cookieKey] : "";
1449
+ g2.__REPLAY_REQUEST_HEADERS__ = requestInfo.headers;
1450
1450
  const context = { geo: {}, ip: "127.0.0.1", requestId: "replay", server: { region: "local" } };
1451
1451
  const response = await handler(req, context);
1452
1452
  if (response && typeof response === "object" && typeof response.status === "number" && typeof response.text === "function") {
@@ -1536,8 +1536,8 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1536
1536
  console.log(` [network-replay] All ${total} recorded network call(s) were consumed.`);
1537
1537
  }
1538
1538
  globalThis.__REPLAY_RECORDING_MODE__ = false;
1539
- delete g.__REPLAY_REQUEST_COOKIES__;
1540
- delete g.__REPLAY_REQUEST_HEADERS__;
1539
+ delete g2.__REPLAY_REQUEST_COOKIES__;
1540
+ delete g2.__REPLAY_REQUEST_HEADERS__;
1541
1541
  Math.random = origMathRandom;
1542
1542
  cryptoMod.randomBytes = origRandomBytes;
1543
1543
  if (origRandomUUID) cryptoMod.randomUUID = origRandomUUID;
@@ -1548,8 +1548,19 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1548
1548
  }
1549
1549
 
1550
1550
  // src/backendRequests.ts
1551
+ import { webcrypto } from "crypto";
1551
1552
  import { gzipSync } from "zlib";
1552
1553
  import { UTApi } from "uploadthing/server";
1554
+ var g = globalThis;
1555
+ if (typeof g.crypto === "undefined") {
1556
+ g.crypto = {
1557
+ randomUUID: () => webcrypto.randomUUID(),
1558
+ getRandomValues: (buf) => webcrypto.getRandomValues(buf),
1559
+ subtle: webcrypto.subtle
1560
+ };
1561
+ } else if (typeof g.crypto.subtle === "undefined") {
1562
+ g.crypto.subtle = webcrypto.subtle;
1563
+ }
1553
1564
  async function backendRequestsEnsureTable(sql) {
1554
1565
  await sql`
1555
1566
  CREATE TABLE IF NOT EXISTS backend_requests (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replayio-app-building/netlify-recorder",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "Capture and replay Netlify function executions as Replay recordings",
5
5
  "type": "module",
6
6
  "exports": {