@leeguoo/pwtk-network-debugger 1.2.0 → 1.2.2
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.cjs.js +3 -3
- package/dist/index.esm.js +109 -34
- package/dist/index.js +3 -3
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -7146,6 +7146,16 @@ const styles = `
|
|
|
7146
7146
|
#network-debugger-panel.minimized {
|
|
7147
7147
|
height: 40px !important;
|
|
7148
7148
|
overflow: hidden;
|
|
7149
|
+
width: auto !important;
|
|
7150
|
+
min-width: 200px;
|
|
7151
|
+
}
|
|
7152
|
+
|
|
7153
|
+
#network-debugger-panel.minimized .debugger-content {
|
|
7154
|
+
display: none;
|
|
7155
|
+
}
|
|
7156
|
+
|
|
7157
|
+
#network-debugger-panel.minimized .resize-handle {
|
|
7158
|
+
display: none;
|
|
7149
7159
|
}
|
|
7150
7160
|
|
|
7151
7161
|
#network-debugger-panel.bottom-right {
|
|
@@ -7620,28 +7630,30 @@ const styles = `
|
|
|
7620
7630
|
`;
|
|
7621
7631
|
async function createShareLink(requestData) {
|
|
7622
7632
|
try {
|
|
7633
|
+
const curlCommand = formatAsCurl(requestData);
|
|
7623
7634
|
const shareData = {
|
|
7624
|
-
//
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7635
|
+
// 原项目需要的核心字段
|
|
7636
|
+
curl: curlCommand,
|
|
7637
|
+
response: requestData.responseBody || null,
|
|
7638
|
+
timestamp: Date.now(),
|
|
7639
|
+
// 密钥相关(如果有)
|
|
7640
|
+
keys: extractKeys(requestData.headers),
|
|
7641
|
+
slk: requestData.headers?.slk || "",
|
|
7642
|
+
// 额外的调试信息(向后兼容)
|
|
7643
|
+
debuggerData: {
|
|
7644
|
+
url: requestData.url,
|
|
7645
|
+
method: requestData.method,
|
|
7646
|
+
headers: requestData.headers,
|
|
7647
|
+
status: requestData.status,
|
|
7648
|
+
statusText: requestData.statusText,
|
|
7649
|
+
duration: requestData.duration,
|
|
7650
|
+
responseHeaders: requestData.responseHeaders,
|
|
7651
|
+
decryptedRequest: requestData.decryptedRequest,
|
|
7652
|
+
decryptedResponse: requestData.decryptedResponse,
|
|
7653
|
+
error: requestData.error,
|
|
7654
|
+
creator: "PWTK Network Debugger by Leo (@leeguoo)",
|
|
7655
|
+
version: "1.2.0"
|
|
7656
|
+
}
|
|
7645
7657
|
};
|
|
7646
7658
|
const response = await fetch("https://gw-card-pay.buyacard.cc/api/dokv/storage", {
|
|
7647
7659
|
method: "POST",
|
|
@@ -7649,15 +7661,22 @@ async function createShareLink(requestData) {
|
|
|
7649
7661
|
"Content-Type": "application/json"
|
|
7650
7662
|
},
|
|
7651
7663
|
body: JSON.stringify({
|
|
7664
|
+
projectId: "curl-tool",
|
|
7665
|
+
// 使用与原项目相同的项目ID
|
|
7666
|
+
key: `share:${generateShareId()}`,
|
|
7667
|
+
// 使用相同的key格式
|
|
7652
7668
|
data: shareData,
|
|
7653
|
-
type: "network-request",
|
|
7654
7669
|
expireIn: 7 * 24 * 60 * 60 * 1e3
|
|
7655
7670
|
// 7天过期
|
|
7656
7671
|
})
|
|
7657
7672
|
});
|
|
7658
7673
|
const result = await response.json();
|
|
7659
|
-
if (result.success && result.id) {
|
|
7660
|
-
|
|
7674
|
+
if (result.success && (result.id || result.key)) {
|
|
7675
|
+
let shareId = result.id;
|
|
7676
|
+
if (!shareId && result.key) {
|
|
7677
|
+
shareId = result.key.replace("share:", "");
|
|
7678
|
+
}
|
|
7679
|
+
const shareUrl = `https://curl.bwg.leeguoo.com/share/${shareId}`;
|
|
7661
7680
|
console.log(`🔗 分享链接创建成功 (by Leo): ${shareUrl}`);
|
|
7662
7681
|
return shareUrl;
|
|
7663
7682
|
} else {
|
|
@@ -7668,6 +7687,13 @@ async function createShareLink(requestData) {
|
|
|
7668
7687
|
throw error;
|
|
7669
7688
|
}
|
|
7670
7689
|
}
|
|
7690
|
+
function generateShareId() {
|
|
7691
|
+
return Math.random().toString(36).substr(2, 10);
|
|
7692
|
+
}
|
|
7693
|
+
function extractKeys(headers) {
|
|
7694
|
+
if (!headers) return "";
|
|
7695
|
+
return headers.keys || headers.cid || headers["x-api-key"] || "";
|
|
7696
|
+
}
|
|
7671
7697
|
async function copyToClipboard(text) {
|
|
7672
7698
|
try {
|
|
7673
7699
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
@@ -7689,6 +7715,22 @@ async function copyToClipboard(text) {
|
|
|
7689
7715
|
return false;
|
|
7690
7716
|
}
|
|
7691
7717
|
}
|
|
7718
|
+
function formatAsCurl(requestData) {
|
|
7719
|
+
let curl = `curl '${requestData.url}'`;
|
|
7720
|
+
if (requestData.method !== "GET") {
|
|
7721
|
+
curl += ` -X ${requestData.method}`;
|
|
7722
|
+
}
|
|
7723
|
+
if (requestData.headers) {
|
|
7724
|
+
Object.entries(requestData.headers).forEach(([key, value]) => {
|
|
7725
|
+
curl += ` -H '${key}: ${value}'`;
|
|
7726
|
+
});
|
|
7727
|
+
}
|
|
7728
|
+
if (requestData.requestBody) {
|
|
7729
|
+
const body = typeof requestData.requestBody === "string" ? requestData.requestBody : JSON.stringify(requestData.requestBody);
|
|
7730
|
+
curl += ` --data '${body}'`;
|
|
7731
|
+
}
|
|
7732
|
+
return curl;
|
|
7733
|
+
}
|
|
7692
7734
|
class DebugPanel {
|
|
7693
7735
|
constructor(interceptor, config = {}) {
|
|
7694
7736
|
this.isDragging = false;
|
|
@@ -7721,12 +7763,12 @@ class DebugPanel {
|
|
|
7721
7763
|
this.container.className = `${this.config.position} ${this.config.minimized ? "minimized" : ""}`;
|
|
7722
7764
|
this.container.innerHTML = `
|
|
7723
7765
|
<div class="debugger-header">
|
|
7724
|
-
<div class="debugger-title"
|
|
7766
|
+
<div class="debugger-title">🔓 ${this.config.minimized ? "PWTK" : "PWTK 解密小工具"} <span style="font-size: 10px; opacity: 0.7;">by Leo</span></div>
|
|
7725
7767
|
<div class="debugger-controls">
|
|
7726
|
-
<button class="debugger-btn" data-action="clear" title="清空">🗑️</button>
|
|
7727
|
-
<button class="debugger-btn" data-action="export" title="导出">💾</button>
|
|
7728
|
-
<button class="debugger-btn" data-action="minimize" title="最小化">${this.config.minimized ? "📖" : "📕"}</button>
|
|
7729
|
-
<button class="debugger-btn" data-action="fullscreen" title="全屏">⛶</button>
|
|
7768
|
+
${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="清空">🗑️</button>' : ""}
|
|
7769
|
+
${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="导出">💾</button>' : ""}
|
|
7770
|
+
<button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "最小化"}">${this.config.minimized ? "📖" : "📕"}</button>
|
|
7771
|
+
${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏">⛶</button>' : ""}
|
|
7730
7772
|
<button class="debugger-btn" data-action="close" title="关闭">✕</button>
|
|
7731
7773
|
</div>
|
|
7732
7774
|
</div>
|
|
@@ -7765,8 +7807,8 @@ class DebugPanel {
|
|
|
7765
7807
|
</div>
|
|
7766
7808
|
<div class="about-panel" data-panel="about" style="display: none;">
|
|
7767
7809
|
<div style="padding: 20px; color: #fff; text-align: center;">
|
|
7768
|
-
<h2 style="margin: 0 0 20px 0;"
|
|
7769
|
-
<p style="margin: 10px 0;">Version: 1.2.
|
|
7810
|
+
<h2 style="margin: 0 0 20px 0;">🔓 PWTK 解密小工具</h2>
|
|
7811
|
+
<p style="margin: 10px 0;">Version: 1.2.2</p>
|
|
7770
7812
|
<p style="margin: 10px 0;">👨💻 Created by <strong>Leo (@leeguoo)</strong></p>
|
|
7771
7813
|
<p style="margin: 10px 0;">📧 技术支持:请联系 Leo</p>
|
|
7772
7814
|
<p style="margin: 10px 0;">🌐 分享服务:curl.bwg.leeguoo.com</p>
|
|
@@ -8087,8 +8129,41 @@ Created by Leo (@leeguoo)`);
|
|
|
8087
8129
|
toggleMinimize() {
|
|
8088
8130
|
this.config.minimized = !this.config.minimized;
|
|
8089
8131
|
this.container.classList.toggle("minimized", this.config.minimized);
|
|
8090
|
-
const
|
|
8091
|
-
|
|
8132
|
+
const header = this.container.querySelector(".debugger-header");
|
|
8133
|
+
if (header) {
|
|
8134
|
+
header.innerHTML = `
|
|
8135
|
+
<div class="debugger-title">🔓 ${this.config.minimized ? "PWTK" : "PWTK 解密小工具"} <span style="font-size: 10px; opacity: 0.7;">by Leo</span></div>
|
|
8136
|
+
<div class="debugger-controls">
|
|
8137
|
+
${!this.config.minimized ? '<button class="debugger-btn" data-action="clear" title="清空">🗑️</button>' : ""}
|
|
8138
|
+
${!this.config.minimized ? '<button class="debugger-btn" data-action="export" title="导出">💾</button>' : ""}
|
|
8139
|
+
<button class="debugger-btn" data-action="minimize" title="${this.config.minimized ? "展开" : "最小化"}">${this.config.minimized ? "📖" : "📕"}</button>
|
|
8140
|
+
${!this.config.minimized ? '<button class="debugger-btn" data-action="fullscreen" title="全屏">⛶</button>' : ""}
|
|
8141
|
+
<button class="debugger-btn" data-action="close" title="关闭">✕</button>
|
|
8142
|
+
</div>
|
|
8143
|
+
`;
|
|
8144
|
+
const controls = header.querySelector(".debugger-controls");
|
|
8145
|
+
controls.addEventListener("click", (e) => {
|
|
8146
|
+
const target = e.target;
|
|
8147
|
+
const action = target.dataset.action;
|
|
8148
|
+
switch (action) {
|
|
8149
|
+
case "clear":
|
|
8150
|
+
this.clearRequests();
|
|
8151
|
+
break;
|
|
8152
|
+
case "export":
|
|
8153
|
+
this.exportData();
|
|
8154
|
+
break;
|
|
8155
|
+
case "minimize":
|
|
8156
|
+
this.toggleMinimize();
|
|
8157
|
+
break;
|
|
8158
|
+
case "fullscreen":
|
|
8159
|
+
this.toggleFullscreen();
|
|
8160
|
+
break;
|
|
8161
|
+
case "close":
|
|
8162
|
+
this.hide();
|
|
8163
|
+
break;
|
|
8164
|
+
}
|
|
8165
|
+
});
|
|
8166
|
+
}
|
|
8092
8167
|
}
|
|
8093
8168
|
toggleFullscreen() {
|
|
8094
8169
|
this.container.classList.toggle("fullscreen");
|
|
@@ -8330,7 +8405,7 @@ class NetworkDebugger {
|
|
|
8330
8405
|
this.initialized = true;
|
|
8331
8406
|
console.log(`
|
|
8332
8407
|
╔════════════════════════════════════════╗
|
|
8333
|
-
║ PWTK
|
|
8408
|
+
║ 🔓 PWTK 解密小工具 v1.2.2 ║
|
|
8334
8409
|
║ Created by Leo (@leeguoo) ║
|
|
8335
8410
|
║ 技术支持: 请联系 Leo ║
|
|
8336
8411
|
║ 分享服务: curl.bwg.leeguoo.com ║
|