@leeguoo/pwtk-network-debugger 1.2.2 → 1.2.3
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 +100 -44
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6711,6 +6711,9 @@ class NetworkInterceptor {
|
|
|
6711
6711
|
generateRequestId() {
|
|
6712
6712
|
return Math.random().toString(36).substr(2, 9);
|
|
6713
6713
|
}
|
|
6714
|
+
isInternalUrl(url) {
|
|
6715
|
+
return url.includes("/ip/getSK") || url.includes("/api/dokv/storage") || url.includes("/api/share");
|
|
6716
|
+
}
|
|
6714
6717
|
notifyListeners(request) {
|
|
6715
6718
|
this.listeners.forEach((listener) => {
|
|
6716
6719
|
try {
|
|
@@ -6781,10 +6784,12 @@ class NetworkInterceptor {
|
|
|
6781
6784
|
let url = "";
|
|
6782
6785
|
let requestHeaders = {};
|
|
6783
6786
|
const startTime = Date.now();
|
|
6787
|
+
let isInternalRequest = false;
|
|
6784
6788
|
const originalOpen = xhr.open;
|
|
6785
6789
|
xhr.open = function(methodArg, urlArg, ...rest) {
|
|
6786
6790
|
method = methodArg.toUpperCase();
|
|
6787
6791
|
url = urlArg;
|
|
6792
|
+
isInternalRequest = self2.isInternalUrl(url);
|
|
6788
6793
|
return originalOpen.apply(this, [methodArg, urlArg, ...rest]);
|
|
6789
6794
|
};
|
|
6790
6795
|
const originalSetRequestHeader = xhr.setRequestHeader;
|
|
@@ -6794,6 +6799,9 @@ class NetworkInterceptor {
|
|
|
6794
6799
|
};
|
|
6795
6800
|
const originalSend = xhr.send;
|
|
6796
6801
|
xhr.send = function(body) {
|
|
6802
|
+
if (isInternalRequest) {
|
|
6803
|
+
return originalSend.call(this, body);
|
|
6804
|
+
}
|
|
6797
6805
|
const requestData = {
|
|
6798
6806
|
id: requestId,
|
|
6799
6807
|
url,
|
|
@@ -6816,7 +6824,7 @@ class NetworkInterceptor {
|
|
|
6816
6824
|
return originalSend.call(this, body);
|
|
6817
6825
|
};
|
|
6818
6826
|
xhr.addEventListener("readystatechange", function() {
|
|
6819
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
6827
|
+
if (xhr.readyState === XMLHttpRequest.DONE && !isInternalRequest) {
|
|
6820
6828
|
const endTime = Date.now();
|
|
6821
6829
|
const requestData = self2.requests.get(requestId);
|
|
6822
6830
|
if (requestData) {
|
|
@@ -6858,13 +6866,16 @@ class NetworkInterceptor {
|
|
|
6858
6866
|
window.XMLHttpRequest.prototype = originalXHR.prototype;
|
|
6859
6867
|
}
|
|
6860
6868
|
interceptFetch() {
|
|
6861
|
-
const originalFetch = window.fetch;
|
|
6869
|
+
const originalFetch = window.fetch(window).__originalFetch = originalFetch;
|
|
6862
6870
|
const self2 = this;
|
|
6863
6871
|
window.fetch = async function(input, init) {
|
|
6864
6872
|
const requestId = self2.generateRequestId();
|
|
6865
6873
|
const startTime = Date.now();
|
|
6866
6874
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
6867
6875
|
const method = (init?.method || "GET").toUpperCase();
|
|
6876
|
+
if (self2.isInternalUrl(url)) {
|
|
6877
|
+
return originalFetch.call(this, input, init);
|
|
6878
|
+
}
|
|
6868
6879
|
const requestHeaders = {};
|
|
6869
6880
|
if (init?.headers) {
|
|
6870
6881
|
if (init.headers instanceof Headers) {
|
|
@@ -7364,6 +7375,19 @@ const styles = `
|
|
|
7364
7375
|
display: none;
|
|
7365
7376
|
}
|
|
7366
7377
|
|
|
7378
|
+
/* 默认折叠headers */
|
|
7379
|
+
.request-details .detail-section.collapsible {
|
|
7380
|
+
/* 默认折叠状态 */
|
|
7381
|
+
}
|
|
7382
|
+
|
|
7383
|
+
.request-details .detail-section.collapsible:not(.expanded) .detail-content {
|
|
7384
|
+
display: none;
|
|
7385
|
+
}
|
|
7386
|
+
|
|
7387
|
+
.request-details .detail-section.collapsible:not(.expanded) .collapse-icon {
|
|
7388
|
+
transform: rotate(-90deg);
|
|
7389
|
+
}
|
|
7390
|
+
|
|
7367
7391
|
.request-item.expanded .request-details {
|
|
7368
7392
|
display: block;
|
|
7369
7393
|
}
|
|
@@ -7382,6 +7406,45 @@ const styles = `
|
|
|
7382
7406
|
padding-bottom: 4px;
|
|
7383
7407
|
}
|
|
7384
7408
|
|
|
7409
|
+
.detail-title.highlight {
|
|
7410
|
+
color: #FFD700;
|
|
7411
|
+
font-size: 12px;
|
|
7412
|
+
background: rgba(255, 215, 0, 0.1);
|
|
7413
|
+
padding: 6px 8px;
|
|
7414
|
+
border-radius: 4px;
|
|
7415
|
+
border-bottom: 2px solid #FFD700;
|
|
7416
|
+
}
|
|
7417
|
+
|
|
7418
|
+
.detail-title.clickable {
|
|
7419
|
+
cursor: pointer;
|
|
7420
|
+
user-select: none;
|
|
7421
|
+
display: flex;
|
|
7422
|
+
align-items: center;
|
|
7423
|
+
gap: 4px;
|
|
7424
|
+
}
|
|
7425
|
+
|
|
7426
|
+
.detail-title.clickable:hover {
|
|
7427
|
+
background: rgba(76, 175, 80, 0.1);
|
|
7428
|
+
}
|
|
7429
|
+
|
|
7430
|
+
.collapse-icon {
|
|
7431
|
+
display: inline-block;
|
|
7432
|
+
transition: transform 0.2s;
|
|
7433
|
+
font-size: 10px;
|
|
7434
|
+
}
|
|
7435
|
+
|
|
7436
|
+
.detail-section.collapsible {
|
|
7437
|
+
position: relative;
|
|
7438
|
+
}
|
|
7439
|
+
|
|
7440
|
+
.detail-section.collapsible.collapsed .detail-content {
|
|
7441
|
+
display: none;
|
|
7442
|
+
}
|
|
7443
|
+
|
|
7444
|
+
.detail-section.collapsible.collapsed .collapse-icon {
|
|
7445
|
+
transform: rotate(-90deg);
|
|
7446
|
+
}
|
|
7447
|
+
|
|
7385
7448
|
.detail-content {
|
|
7386
7449
|
background: #222;
|
|
7387
7450
|
padding: 8px;
|
|
@@ -7655,41 +7718,29 @@ async function createShareLink(requestData) {
|
|
|
7655
7718
|
version: "1.2.0"
|
|
7656
7719
|
}
|
|
7657
7720
|
};
|
|
7658
|
-
const
|
|
7721
|
+
const originalFetch = window.__originalFetch || window.fetch;
|
|
7722
|
+
const response = await originalFetch("https://curl.bwg.leeguoo.com/api/share", {
|
|
7659
7723
|
method: "POST",
|
|
7660
7724
|
headers: {
|
|
7661
7725
|
"Content-Type": "application/json"
|
|
7662
7726
|
},
|
|
7663
7727
|
body: JSON.stringify({
|
|
7664
|
-
|
|
7665
|
-
// 使用与原项目相同的项目ID
|
|
7666
|
-
key: `share:${generateShareId()}`,
|
|
7667
|
-
// 使用相同的key格式
|
|
7668
|
-
data: shareData,
|
|
7669
|
-
expireIn: 7 * 24 * 60 * 60 * 1e3
|
|
7670
|
-
// 7天过期
|
|
7728
|
+
data: shareData
|
|
7671
7729
|
})
|
|
7672
7730
|
});
|
|
7673
7731
|
const result = await response.json();
|
|
7674
|
-
if (result.
|
|
7675
|
-
|
|
7676
|
-
if (!shareId && result.key) {
|
|
7677
|
-
shareId = result.key.replace("share:", "");
|
|
7678
|
-
}
|
|
7679
|
-
const shareUrl = `https://curl.bwg.leeguoo.com/share/${shareId}`;
|
|
7732
|
+
if (result.shareId) {
|
|
7733
|
+
const shareUrl = `https://curl.bwg.leeguoo.com/share/${result.shareId}`;
|
|
7680
7734
|
console.log(`🔗 分享链接创建成功 (by Leo): ${shareUrl}`);
|
|
7681
7735
|
return shareUrl;
|
|
7682
7736
|
} else {
|
|
7683
|
-
throw new Error(result.
|
|
7737
|
+
throw new Error(result.error || "创建分享失败");
|
|
7684
7738
|
}
|
|
7685
7739
|
} catch (error) {
|
|
7686
7740
|
console.error("NetworkDebugger: 创建分享链接失败:", error);
|
|
7687
7741
|
throw error;
|
|
7688
7742
|
}
|
|
7689
7743
|
}
|
|
7690
|
-
function generateShareId() {
|
|
7691
|
-
return Math.random().toString(36).substr(2, 10);
|
|
7692
|
-
}
|
|
7693
7744
|
function extractKeys(headers) {
|
|
7694
7745
|
if (!headers) return "";
|
|
7695
7746
|
return headers.keys || headers.cid || headers["x-api-key"] || "";
|
|
@@ -7808,7 +7859,7 @@ class DebugPanel {
|
|
|
7808
7859
|
<div class="about-panel" data-panel="about" style="display: none;">
|
|
7809
7860
|
<div style="padding: 20px; color: #fff; text-align: center;">
|
|
7810
7861
|
<h2 style="margin: 0 0 20px 0;">🔓 PWTK 解密小工具</h2>
|
|
7811
|
-
<p style="margin: 10px 0;">Version: 1.2.
|
|
7862
|
+
<p style="margin: 10px 0;">Version: 1.2.3</p>
|
|
7812
7863
|
<p style="margin: 10px 0;">👨💻 Created by <strong>Leo (@leeguoo)</strong></p>
|
|
7813
7864
|
<p style="margin: 10px 0;">📧 技术支持:请联系 Leo</p>
|
|
7814
7865
|
<p style="margin: 10px 0;">🌐 分享服务:curl.bwg.leeguoo.com</p>
|
|
@@ -7961,44 +8012,49 @@ class DebugPanel {
|
|
|
7961
8012
|
}
|
|
7962
8013
|
renderRequestDetails(request) {
|
|
7963
8014
|
let html = "";
|
|
7964
|
-
|
|
8015
|
+
request.id.replace(/[^a-zA-Z0-9]/g, "");
|
|
8016
|
+
if (request.decryptedRequest) {
|
|
7965
8017
|
html += `
|
|
7966
8018
|
<div class="detail-section">
|
|
7967
|
-
<div class="detail-title"
|
|
8019
|
+
<div class="detail-title highlight">🔓 解密请求数据</div>
|
|
7968
8020
|
<div class="detail-content">
|
|
7969
|
-
<
|
|
7970
|
-
${Object.entries(request.headers).map(
|
|
7971
|
-
([key, value]) => `<tr><td>${key}</td><td>${value}</td></tr>`
|
|
7972
|
-
).join("")}
|
|
7973
|
-
</table>
|
|
8021
|
+
<div class="json-content">${this.formatData(request.decryptedRequest)}</div>
|
|
7974
8022
|
</div>
|
|
7975
8023
|
</div>
|
|
7976
8024
|
`;
|
|
7977
8025
|
}
|
|
7978
|
-
if (request.
|
|
8026
|
+
if (request.decryptedResponse) {
|
|
7979
8027
|
html += `
|
|
7980
8028
|
<div class="detail-section">
|
|
7981
|
-
<div class="detail-title"
|
|
8029
|
+
<div class="detail-title highlight">🔓 解密响应数据</div>
|
|
7982
8030
|
<div class="detail-content">
|
|
7983
|
-
<div class="json-content">${this.formatData(request.
|
|
8031
|
+
<div class="json-content">${this.formatData(request.decryptedResponse)}</div>
|
|
7984
8032
|
</div>
|
|
7985
8033
|
</div>
|
|
7986
8034
|
`;
|
|
7987
8035
|
}
|
|
7988
|
-
if (request.
|
|
8036
|
+
if (Object.keys(request.headers).length > 0) {
|
|
7989
8037
|
html += `
|
|
7990
|
-
<div class="detail-section">
|
|
7991
|
-
<div class="detail-title"
|
|
8038
|
+
<div class="detail-section collapsible collapsed">
|
|
8039
|
+
<div class="detail-title clickable" onclick="this.parentElement.classList.toggle('collapsed')">
|
|
8040
|
+
<span class="collapse-icon">▼</span> 请求头 (${Object.keys(request.headers).length})
|
|
8041
|
+
</div>
|
|
7992
8042
|
<div class="detail-content">
|
|
7993
|
-
<
|
|
8043
|
+
<table class="headers-table">
|
|
8044
|
+
${Object.entries(request.headers).map(
|
|
8045
|
+
([key, value]) => `<tr><td>${key}</td><td>${value}</td></tr>`
|
|
8046
|
+
).join("")}
|
|
8047
|
+
</table>
|
|
7994
8048
|
</div>
|
|
7995
8049
|
</div>
|
|
7996
8050
|
`;
|
|
7997
8051
|
}
|
|
7998
8052
|
if (request.responseHeaders && Object.keys(request.responseHeaders).length > 0) {
|
|
7999
8053
|
html += `
|
|
8000
|
-
<div class="detail-section">
|
|
8001
|
-
<div class="detail-title"
|
|
8054
|
+
<div class="detail-section collapsible collapsed">
|
|
8055
|
+
<div class="detail-title clickable" onclick="this.parentElement.classList.toggle('collapsed')">
|
|
8056
|
+
<span class="collapse-icon">▼</span> 响应头 (${Object.keys(request.responseHeaders).length})
|
|
8057
|
+
</div>
|
|
8002
8058
|
<div class="detail-content">
|
|
8003
8059
|
<table class="headers-table">
|
|
8004
8060
|
${Object.entries(request.responseHeaders).map(
|
|
@@ -8009,22 +8065,22 @@ class DebugPanel {
|
|
|
8009
8065
|
</div>
|
|
8010
8066
|
`;
|
|
8011
8067
|
}
|
|
8012
|
-
if (request.
|
|
8068
|
+
if (request.requestBody && !request.decryptedRequest) {
|
|
8013
8069
|
html += `
|
|
8014
8070
|
<div class="detail-section">
|
|
8015
|
-
<div class="detail-title"
|
|
8071
|
+
<div class="detail-title">请求数据</div>
|
|
8016
8072
|
<div class="detail-content">
|
|
8017
|
-
<div class="json-content">${this.formatData(request.
|
|
8073
|
+
<div class="json-content">${this.formatData(request.requestBody)}</div>
|
|
8018
8074
|
</div>
|
|
8019
8075
|
</div>
|
|
8020
8076
|
`;
|
|
8021
8077
|
}
|
|
8022
|
-
if (request.decryptedResponse) {
|
|
8078
|
+
if (request.responseBody && !request.decryptedResponse) {
|
|
8023
8079
|
html += `
|
|
8024
8080
|
<div class="detail-section">
|
|
8025
|
-
<div class="detail-title"
|
|
8081
|
+
<div class="detail-title">响应数据</div>
|
|
8026
8082
|
<div class="detail-content">
|
|
8027
|
-
<div class="json-content">${this.formatData(request.
|
|
8083
|
+
<div class="json-content">${this.formatData(request.responseBody)}</div>
|
|
8028
8084
|
</div>
|
|
8029
8085
|
</div>
|
|
8030
8086
|
`;
|
|
@@ -8405,7 +8461,7 @@ class NetworkDebugger {
|
|
|
8405
8461
|
this.initialized = true;
|
|
8406
8462
|
console.log(`
|
|
8407
8463
|
╔════════════════════════════════════════╗
|
|
8408
|
-
║ 🔓 PWTK 解密小工具 v1.2.
|
|
8464
|
+
║ 🔓 PWTK 解密小工具 v1.2.3 ║
|
|
8409
8465
|
║ Created by Leo (@leeguoo) ║
|
|
8410
8466
|
║ 技术支持: 请联系 Leo ║
|
|
8411
8467
|
║ 分享服务: curl.bwg.leeguoo.com ║
|