@leeguoo/pwtk-network-debugger 1.2.28 β†’ 1.2.30

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.esm.js CHANGED
@@ -6850,6 +6850,25 @@ class NetworkInterceptor {
6850
6850
  }
6851
6851
  });
6852
6852
  }
6853
+ extractUrlParams(url) {
6854
+ try {
6855
+ const urlObj = new URL(url);
6856
+ const params = {};
6857
+ urlObj.searchParams.forEach((value, key) => {
6858
+ params[key] = value;
6859
+ });
6860
+ if (Object.keys(params).length > 0) {
6861
+ if (Object.keys(params).length === 1 && params.data) {
6862
+ return params.data;
6863
+ } else {
6864
+ return params;
6865
+ }
6866
+ }
6867
+ return null;
6868
+ } catch (e) {
6869
+ return null;
6870
+ }
6871
+ }
6853
6872
  async tryDecrypt(data, headers) {
6854
6873
  logger.debug("[PWTK Debug] tryDecrypt called:", {
6855
6874
  dataType: typeof data,
@@ -6998,8 +7017,15 @@ class NetworkInterceptor {
6998
7017
  requestBody: body,
6999
7018
  timestamp: startTime
7000
7019
  };
7001
- if (body) {
7002
- self2.tryDecrypt(body, requestHeaders).then((decrypted) => {
7020
+ let dataToDecrypt = body;
7021
+ if (method === "GET" && !body) {
7022
+ dataToDecrypt = self2.extractUrlParams(url);
7023
+ if (dataToDecrypt) {
7024
+ requestData.requestBody = dataToDecrypt;
7025
+ }
7026
+ }
7027
+ if (dataToDecrypt) {
7028
+ self2.tryDecrypt(dataToDecrypt, requestHeaders).then((decrypted) => {
7003
7029
  if (decrypted !== null) {
7004
7030
  requestData.decryptedRequest = decrypted;
7005
7031
  self2.requests.set(requestId, requestData);
@@ -7136,8 +7162,15 @@ class NetworkInterceptor {
7136
7162
  requestBody,
7137
7163
  timestamp: startTime
7138
7164
  };
7139
- if (requestBody) {
7140
- self2.tryDecrypt(requestBody, requestHeaders).then((decrypted) => {
7165
+ let dataToDecrypt = requestBody;
7166
+ if (method === "GET" && !requestBody) {
7167
+ dataToDecrypt = self2.extractUrlParams(url);
7168
+ if (dataToDecrypt) {
7169
+ requestData.requestBody = dataToDecrypt;
7170
+ }
7171
+ }
7172
+ if (dataToDecrypt) {
7173
+ self2.tryDecrypt(dataToDecrypt, requestHeaders).then((decrypted) => {
7141
7174
  if (decrypted !== null) {
7142
7175
  requestData.decryptedRequest = decrypted;
7143
7176
  self2.requests.set(requestId, requestData);
@@ -7368,7 +7401,7 @@ function parseCurl(curlCommand) {
7368
7401
  const lines = curlCommand.split("\\\n").map((line) => line.trim());
7369
7402
  const fullCommand = lines.join(" ");
7370
7403
  const urlMatch = fullCommand.match(/c?curl\s+['"]?([^'"\s]+)['"]?/);
7371
- const url = urlMatch ? urlMatch[1] : "";
7404
+ let url = urlMatch ? urlMatch[1] : "";
7372
7405
  const headers = {};
7373
7406
  const headerMatches = fullCommand.matchAll(/-H\s+['"]([^:]+):\s*([^'"]*)['"]/g);
7374
7407
  for (const match of headerMatches) {
@@ -7384,8 +7417,25 @@ function parseCurl(curlCommand) {
7384
7417
  data = rawData;
7385
7418
  }
7386
7419
  }
7420
+ if (!dataMatch && url.includes("?")) {
7421
+ try {
7422
+ const urlObj = new URL(url, "http://example.com");
7423
+ const params = {};
7424
+ urlObj.searchParams.forEach((value, key) => {
7425
+ params[key] = value;
7426
+ });
7427
+ if (Object.keys(params).length > 0) {
7428
+ if (Object.keys(params).length === 1 && params.data) {
7429
+ data = params.data;
7430
+ } else {
7431
+ data = params;
7432
+ }
7433
+ }
7434
+ } catch (e) {
7435
+ }
7436
+ }
7387
7437
  const methodMatch = fullCommand.match(/-X\s+(['"]?)([A-Z]+)\1/);
7388
- let method = methodMatch ? methodMatch[2] : data ? "POST" : "GET";
7438
+ let method = methodMatch ? methodMatch[2] : dataMatch ? "POST" : "GET";
7389
7439
  return {
7390
7440
  url,
7391
7441
  method,
@@ -8127,12 +8177,11 @@ const _DebugPanel = class _DebugPanel {
8127
8177
  this.container.className = `${this.config.position} ${this.config.minimized ? "minimized" : ""}`;
8128
8178
  this.container.innerHTML = `
8129
8179
  <div class="debugger-header">
8130
- <div class="debugger-title">πŸ”“ ${this.config.minimized ? "PWTK" : "PWTK 解密小ε·₯ε…·"} <span style="font-size: 10px; opacity: 0.7;">by Leo</span></div>
8180
+ <div class="debugger-title">πŸ”“ PWTK 解密小ε·₯ε…· <span style="font-size: 10px; opacity: 0.7;">by Leo</span></div>
8131
8181
  <div class="debugger-controls">
8132
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="ζΈ…η©Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg></button>' : ""}
8133
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="ε―Όε‡Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg></button>' : ""}
8134
- <button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "ζœ€ε°εŒ–"}"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="${this.config.minimized ? "M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z" : "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}"/></svg></button>
8135
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg></button>' : ""}
8182
+ <button class="debugger-btn" data-action="clear" title="ζΈ…η©Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg></button>
8183
+ <button class="debugger-btn" data-action="export" title="ε―Όε‡Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg></button>
8184
+ <button class="debugger-btn" data-action="fullscreen" title="全屏"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg></button>
8136
8185
  <button class="debugger-btn" data-action="close" title="ε…³ι—­"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg></button>
8137
8186
  </div>
8138
8187
  </div>
@@ -8226,9 +8275,6 @@ const _DebugPanel = class _DebugPanel {
8226
8275
  case "export":
8227
8276
  this.exportData();
8228
8277
  break;
8229
- case "minimize":
8230
- this.toggleMinimize();
8231
- break;
8232
8278
  case "fullscreen":
8233
8279
  this.toggleFullscreen();
8234
8280
  break;
@@ -8340,6 +8386,17 @@ const _DebugPanel = class _DebugPanel {
8340
8386
  await this.shareRequest(request);
8341
8387
  });
8342
8388
  }
8389
+ item.addEventListener("click", (e) => {
8390
+ const target = e.target;
8391
+ if (target.closest('.detail-title[data-toggle="collapse"]')) {
8392
+ e.stopPropagation();
8393
+ const detailTitle = target.closest(".detail-title");
8394
+ const detailSection = detailTitle.parentElement;
8395
+ if (detailSection && detailSection.classList.contains("collapsible")) {
8396
+ detailSection.classList.toggle("collapsed");
8397
+ }
8398
+ }
8399
+ });
8343
8400
  return item;
8344
8401
  }
8345
8402
  renderRequestDetails(request) {
@@ -8368,7 +8425,7 @@ const _DebugPanel = class _DebugPanel {
8368
8425
  if (Object.keys(request.headers).length > 0) {
8369
8426
  html += `
8370
8427
  <div class="detail-section collapsible collapsed">
8371
- <div class="detail-title clickable" onclick="this.parentElement.classList.toggle('collapsed')">
8428
+ <div class="detail-title clickable" data-toggle="collapse">
8372
8429
  <span class="collapse-icon">β–Ό</span> 请求倴 (${Object.keys(request.headers).length})
8373
8430
  </div>
8374
8431
  <div class="detail-content">
@@ -8384,7 +8441,7 @@ const _DebugPanel = class _DebugPanel {
8384
8441
  if (request.responseHeaders && Object.keys(request.responseHeaders).length > 0) {
8385
8442
  html += `
8386
8443
  <div class="detail-section collapsible collapsed">
8387
- <div class="detail-title clickable" onclick="this.parentElement.classList.toggle('collapsed')">
8444
+ <div class="detail-title clickable" data-toggle="collapse">
8388
8445
  <span class="collapse-icon">β–Ό</span> 响应倴 (${Object.keys(request.responseHeaders).length})
8389
8446
  </div>
8390
8447
  <div class="detail-content">
@@ -8513,54 +8570,23 @@ Created by Leo (@leeguoo)`);
8513
8570
  alert("εˆ†δΊ«ε€±θ΄₯οΌŒθ―·η¨εŽι‡θ―•");
8514
8571
  }
8515
8572
  }
8516
- toggleMinimize() {
8517
- this.config.minimized = !this.config.minimized;
8518
- this.container.classList.toggle("minimized", this.config.minimized);
8519
- const header = this.container.querySelector(".debugger-header");
8520
- if (header) {
8521
- header.innerHTML = `
8522
- <div class="debugger-title">πŸ”“ ${this.config.minimized ? "PWTK" : "PWTK 解密小ε·₯ε…·"} <span style="font-size: 10px; opacity: 0.7;">by Leo</span></div>
8523
- <div class="debugger-controls">
8524
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="ζΈ…η©Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg></button>' : ""}
8525
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="ε―Όε‡Ί"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/></svg></button>' : ""}
8526
- <button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "ζœ€ε°εŒ–"}"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="${this.config.minimized ? "M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z" : "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}"/></svg></button>
8527
- ${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg></button>' : ""}
8528
- <button class="debugger-btn" data-action="close" title="ε…³ι—­"><svg class="debugger-icon" viewBox="0 0 24 24"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg></button>
8529
- </div>
8530
- `;
8531
- const controls = header.querySelector(".debugger-controls");
8532
- controls.addEventListener("click", (e) => {
8533
- e.stopPropagation();
8534
- let target = e.target;
8535
- while (target && target !== controls) {
8536
- if (target.dataset?.action) break;
8537
- target = target.parentElement;
8538
- }
8539
- const action = target?.dataset?.action;
8540
- if (!action) return;
8541
- switch (action) {
8542
- case "clear":
8543
- this.clearRequests();
8544
- break;
8545
- case "export":
8546
- this.exportData();
8547
- break;
8548
- case "minimize":
8549
- this.toggleMinimize();
8550
- break;
8551
- case "fullscreen":
8552
- this.toggleFullscreen();
8553
- break;
8554
- case "close":
8555
- this.hide();
8556
- break;
8557
- }
8558
- });
8559
- }
8560
- this.saveConfig();
8561
- }
8562
8573
  toggleFullscreen() {
8563
- this.container.classList.toggle("fullscreen");
8574
+ if (this.container.classList.contains("fullscreen")) {
8575
+ this.container.classList.remove("fullscreen");
8576
+ this.container.style.top = "";
8577
+ this.container.style.left = "";
8578
+ this.container.style.width = "";
8579
+ this.container.style.height = "";
8580
+ this.loadPosition();
8581
+ } else {
8582
+ this.container.classList.add("fullscreen");
8583
+ this.container.style.top = "0";
8584
+ this.container.style.left = "0";
8585
+ this.container.style.width = "100vw";
8586
+ this.container.style.height = "100vh";
8587
+ this.container.style.right = "auto";
8588
+ this.container.style.bottom = "auto";
8589
+ }
8564
8590
  }
8565
8591
  handleToolAction(tool) {
8566
8592
  const textarea = this.container.querySelector(".tools-content textarea");
@@ -9032,7 +9058,7 @@ class NetworkDebugger {
9032
9058
  this.initialized = true;
9033
9059
  logger.consoleDirect(`
9034
9060
  ╔════════════════════════════════════════╗
9035
- β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v1.2.28 β•‘
9061
+ β•‘ πŸ”“ PWTK 解密小ε·₯ε…· v1.2.30 β•‘
9036
9062
  β•‘ Created by Leo (@leeguoo) β•‘
9037
9063
  β•‘ ζŠ€ζœ―ζ”―ζŒ: 请联系 Leo β•‘
9038
9064
  β•‘ εˆ†δΊ«ζœεŠ‘: curl.bwg.leeguoo.com β•‘